Saturday, April 05, 2014

include/require in php



include/require in php


Method 1.

Use Absolute path with respect to file system(Not Server root). Best way is to Append file name with  $_SERVER['DOCUMENT_ROOT']" or $_SERVER[DOCUMENT_ROOT'"
For example:
include $_SERVER['DOCUMENT_ROOT']."/htdocs/project/conf.php"
where "/htdocs/project/" is the path of conf.php with respect to server root.

Method 2.

To include the files, path of the file should be  in the include path inside php.ini or file should be in same directory.
 Consider, for example, the following include path, which I use in my php.ini file ;

Windows

include_path = ".;c:php4pear;d:wwwphpinclude" ;


On a Unix server, it might look like this :

include_path = ".:/usr/local/php/lib/php:/home/kyank/phpinclude" ;

No comments:

Post a Comment

Any Suggeston or Query ?