set_include_path() 函數(shù)可以在php程序中動(dòng)態(tài)改變php的 include_path參數(shù),其參數(shù)是一個(gè)字符串,多個(gè)不同的目錄可以串聯(lián)在一起作為一個(gè)參數(shù)一起提交——不同的目錄間使用目錄分割符號(hào)分開,在類unix的系統(tǒng)中這個(gè)分隔符是“:”,在windows系統(tǒng)中這個(gè)分隔符是“;”,所以php提供一個(gè)常量PATH_SEPARATOR 來表示當(dāng)前系統(tǒng)中的這個(gè)分隔符。
set_include_path — 設(shè)置 include_path 配置選項(xiàng)
說明
string set_include_path ( string $new_include_path )
為當(dāng)前腳本設(shè)置 include_path 運(yùn)行時(shí)的配置選項(xiàng)。
參數(shù)
new_include_path
include_path 新的值。
返回值
成功時(shí)返回舊的 include_path 或者在失敗時(shí)返回 FALSE。
實(shí)例一
<?php// 自 PHP 4.3.0 起可用set_include_path('/usr/lib/pear');// 在所有版本的 PHP 中均可用ini_set('include_path', '/usr/lib/pear');?> 實(shí)例二
添加到include path
利用常量 PATH_SEPARATOR 可跨平臺(tái)擴(kuò)展 include path。
這個(gè)例子中我們把 /usr/lib/pear 添加到了 現(xiàn)有的 include_path 的尾部。
<?php$path = '/usr/lib/pear';set_include_path(get_include_path() . PATH_SEPARATOR . $path);?>
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
新聞熱點(diǎn)
疑難解答
圖片精選