PHP 8.3.4 Released!

set_include_path

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

set_include_pathinclude_path 設定オプションをセットする

説明

set_include_path(string $include_path): string|false

include_path 設定オプションの値を、このスクリプト内でだけ変更します。

パラメータ

include_path

include_path の新しい値。

戻り値

成功した場合に元の include_path の値、失敗した場合に false を返します。

例1 set_include_path() の例

<?php
set_include_path
('/usr/lib/pear');

// または ini_set を使用します
ini_set('include_path', '/usr/lib/pear');
?>

例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);
?>

参考

add a note

User Contributed Notes 1 note

up
21
parks at vecinc dot com
14 years ago
If you find that this function is failing for you, and you're not sure why, you may have set your php include path in your sites's conf file in Apache (this may be true of .htaccess as well)

So to get it to work, comment out any "php_value include_path" type lines in your Apache conf file, and you should be able to set it now in your php code.
To Top