Forum Moderators: coopster

Message Too Old, No Replies

includes

full url?

         

kumarsena

3:01 pm on Mar 13, 2004 (gmt 0)

10+ Year Member



when using includes, will suing the full url to the include file make any difference from if ui just used the something like folde/filename?

thijsnetwork

3:04 pm on Mar 13, 2004 (gmt 0)

10+ Year Member



It depends on the situation you are in. If you put all your php files in the root of your webserver, it doesn't make any difference. But I don't think one option is faster or better than the other.

From PHP Manual:
"Files for including are first looked in include_path relative to the current working directory and then in include_path relative to the directory of current script. E.g. if your include_path is ., current working directory is /www/, you included include/a.php and there is include "b.php" in that file, b.php is first looked in /www/ and then in /www/include/."

kumarsena

3:45 pm on Mar 13, 2004 (gmt 0)

10+ Year Member



okie thanks i think i get it now, but i will have to have look at the manual

volatilegx

5:36 pm on Mar 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> But I don't think one option is faster or better than the other.

I believe referring to a file locally is better than using a full URL. Using a full URL may cause the PHP interpreter to use some of your server's bandwidth allowance to pull the file, no?

encyclo

5:57 pm on Mar 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I generally favour the following:

<?php include($_SERVER["DOCUMENT_ROOT"]."/path/to/file.inc.php");?>

Useful if you have a local and a remote version of your site - it works everywhere.

isitreal

9:25 pm on Mar 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



just set the include path in either apache's httpd.conf file or in the main site .htaccess file, that solves all local/ development issues:

php_value include_path ".:/usr/www/users/yoursitefolder/includes"

Of course make this path the right one for your server.

Or better yet, keep the includes folder in another directory than your main site folder:

php_value include_path ".:/usr/www/users/includes"

If your development apache server is running on windows, this path would be this:

php_value include_path ".;c:/web_dev/includes"

[note that in this case the ':' is a ';' for windows paths on apache]

Make the path the right one for your system of course