Howto: PHP setup include_path
Q. How do I set PHP include path?
A. The configuration file php.ini is read when PHP starts up. For the server module versions of PHP, this happens only once when the web server is started. For the CGI and CLI version, it happens on every invocation. This file is use to setup include_path.
Method # 1- Edit php.ini file using vi text editor
Edit your /etc/php.ini file using vi text editor, type the following command at shell prompt (some Linux distro stored file at /etc/php.d/cgi/php.ini location):
# vi /etc/php.ini
Find out include_path directive and change value as per your requirements. For example following includes default path /usr/share/php and current directory. Add /apps/php directory to this path:
include_path = ".:/usr/share/php:/apps/php"
Save and close the file. Restart the web server.
# /etc/init.d/httpd restart
Method # 2 - Use ini_set function
Use ini_set to set include_path value or the given configuration option. It returns the old value on success, FALSE on failure.
For example add following to your own php script:
<? ini_set('include_path',ini_get('include_path').':../includes:'); ?>
OR
<? ini_set("include_path", ".:../:./include:../include"); ?>
Method # 2 is quite useful if your UNIX or Linux hosting provider does not provides access to php.ini file.
E-mail this to a friend
Printable version
Related Other Helpful FAQs:
- How to include files with PHP
- UNIX / Linux: Set your PATH Variable using set or export command
- Why my Apache Server Side Include (SSI) is not working?
- Display or print UNIX / Linux path ~ $PATH variable
- How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!



Recent Comments
Today ~ 2 Comments
Yesterday ~ 10 Comments
Yesterday ~ 12 Comments
09/03/2008 05:29 pm (2 days ago) ~ 6 Comments
09/03/2008 01:14 pm (2 days ago) ~ 1 Comment