N
Glam Fame Journal

How do I set the include path for a PHP file?

Author

Matthew Perez

Updated on April 02, 2026

How do I set the include path for a PHP file?

Open the php.ini file in an editor. You can do this by logging into your account over SSH, or by using the cPanel File Manager. Add the following line to the php.ini file. Replace username with your A2 Hosting username, and replace include_directory with the include directory’s name: Save the file. The include path is now set.

How do I create an include directory in PHP?

You should create the include directory at the username directory level (that is, one level above the public_html directory). This ensures that sensitive files are not in the public_html directory, which anyone can access. You can use a custom php.ini file to specify the include path.

What is the difference between pathinfo and basename in PHP?

The PHP pathinfo () function will give you bearings on a given path: dirname – The directory of the given path. basename – The filename with extension. filename – Filename, without extension. extension – File extension. The basename () function will give you the trailing directory or file of a given path.

How to get the root directory from a string in PHP?

PHP magic constants. And make your path relative. Then D: is what you are looking for, isn’t it? In that case you could explode the string by slashes and return the first one: This will output the server’s root directory.

In order to use .htaccess files to set the include path, PHP must be installed as an Apache module. If PHP is compiled as a CGI binary, you can set the include path in a custom php.ini file (if, for example, you’re being hosted somewhere and don’t have access to the main php.ini file.

What does the include path actually do?

Also, all setting the include path does is set a directory to look in when an include call is made. It’s not a directory where the files should automatically be loaded (which is the impression I get from your post).

How do I configure the include paths for a new project?

To configure the include paths that will be applied to all newly created projects, use the default new project settings ( File | New Projects Setup | Settings/Preferences for New Projects ). On the PHP page that opens, configure the list of include paths on the Include path tab:

Should I use PHP defined paths?

You can always use aboslute paths such as, but it can be a pain to change folders of files later on. As @Discomatt told, using PHP defined paths is a easy way to keep things working. Downside; you have to use PHP. if you use it anyways, no problems ^^