set_include_path

(PHP 4 >= 4.3.0, PHP 5)

set_include_path --  include_path設定オプションをセットする

説明

string set_include_path ( string new_include_path )

スクリプトが動作する間の include_path設定オプション をセットします。成功時に元の include_pathの値を 返します。失敗するとFALSEを返します。

例 1. set_include_path()の例

<?php
// PHP 4.3.0 で動作する
set_include_path('/inc');

// すべての PHP のバージョンで動作する
ini_set('include_path', '/inc');
?>

例 2. include path を追加する

PATH_SEPARATOR 定数を利用することで、 オペレーティングシステムに依存せずに include path を追加する ことが可能です。

この例では、既存の include_path の最後に /usr/lib/pear を追加します。

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

ini_set(), get_include_path(), restore_include_path(), include()も参照してください。