English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

php set_include_path function sets include_path configuration option

The set_include_path() function can dynamically change the include_path parameter in PHP programs. The parameter is a string, and multiple different directories can be concatenated together as a parameter to be submitted together—the directories are separated by a directory separator symbol, in Unix-like systems this separator is “:”, and in Windows systems this separator is “;”. Therefore, PHP provides a constant PATH_SEPARATOR to represent this separator in the current system.

set_include_path — Set include_path configuration options

Description

string set_include_path ( string $new_include_path )

Set runtime configuration options for include_path for the current script.

Parameter

new_include_path

The new value of include_path.

Return value

Returns the old include_path if successful or FALSE if failed.

Example 1

<?php
// Since PHP 4.3.0 available
set_include_path('/usr/lib/pear');
// Available in all versions of PHP
ini_set('include_path', '/usr/lib/pear');
?>

Example 2

Add to include path

Using the constant PATH_SEPARATOR, the include path can be extended across platforms.

In this example, we put /usr/lib/pear has been added to the end of the existing include_path.

<?php
$path = '/usr/lib/pear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
?>

Thank you for reading, I hope it can help everyone, thank you for your support to this site!

You May Also Like