This article describes several methods for setting the include path in PHP. By using include paths, you can centralize code that your web site frequently uses. Additionally, some features, such as PEAR, require you to set the include path so PHP can locate the appropriate files.
If your hosting account includes the cPanel PHP Selector, this is the easiest way to change the include path. To do this, follow these steps:
On the PHP Selector page, click the Options tab:
Under PHP Options, scroll down to the include_path option:
In the text box, type the include path.
You can use a custom php.ini file to specify the include path. If you have not already set up a custom php.ini file, please read this article before you proceed.
To set the include path using a custom php.ini file, follow these steps:
include_path = ".:/home/username/include_directory"
Instead of setting the include path globally in a configuration file, you can set the path directly in a script file. To do this, you use the set_include_path() function.
The following sample code demonstrates how to set the include path using the set_include_path() function. Replace username with your A2 Hosting username:
<?php
set_include_path(".:/usr/lib/php:/usr/local/lib/php:/home/username/php");
?>
A few of our VPS and dedicated servers use Apache modules instead of CGI binaries to run PHP. If your server uses an Apache module to run PHP, you can modify the .htaccess file in your web site's document root directory.
To set the include path using the .htaccess file, follow these steps:
php_value include_path ".:/path"
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.