FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Include file in localhost
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Include file in localhost [message #180685 is a reply to message #180683] Sun, 10 March 2013 04:09 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Sat, 09 Mar 2013 18:16:07 -0800, huynhtoan.it wrote:

> My project(Mysite) have some folder and file as .folderA
> + a.php + b.php
> .folderB
> + c.php
> .folderC
> .folder D
> + d.php
> index.php ................
> when I want to include file a.php in index.php, I have code
> include("folderA/a.php")->I know
>
> when I want to include file a.php in d.php and link to index.php, my
> code must like include(../../folderA/a.php)
> <a href="../../index.php">ex</a>-> It's ok.
>
> But when I have include file d.php in c.php, I have an error:
> a href link to another directory in my warm because a href is
> ../../index.php I try to a href("/Mysite/index.php") But my address in
> google Chrome is
> http://localhost/Mysite/folderC/folderD/localhost/Mysite/index.php ->
> it's wrong Can You give me a method to correct it??

Yes.

Learn the difference between file locations on the server and urls used
by a web client.

Don't use href to include files.

The include file name and path should normally be written in the context
of the server filing system, possibly taking into account the locations
in the file system of the including file and the included file. It should
normally make no reference at all to hrefs or http protocols.

When you write php files that include other php files, you are working
solely within the file system of the php server, and your included and
required file names should be valid within that file system, and not
referenced to some external representation of part of that filesystem as
delivered to other clients over the internet using the http protocol.

(yes I know it is technically possible to include files from other
servers, but seriously, get a copy and load it on your server or suffer
the security risks not to mention the bandwidth penalties)

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: framwork
Next Topic: Senior developer looking for freelance contracts
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 15:07:49 GMT 2024

Total time taken to generate the page: 0.04601 seconds