PHP8 set_include_path — 設置 include_path 配置選項

2023-09-18 16:28 更新

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

set_include_path — 設置 include_path 配置選項

說明

set_include_path(string $include_path): string|false

為當前腳本設置 include_path 運行時的配置選項。

參數(shù)

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。

這個例子中我們把 /usr/lib/pear 添加到了 現(xiàn)有的 include_path 的尾部。

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

參見

  • ini_set() - 為一個配置選項設置值
  • get_include_path() - 獲取當前的 include_path 配置選項
  • restore_include_path() - 還原 include_path 配置選項的值
  • include - include


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號