今日の人気記事

  1. 配列を文字列に変換する - implode()
  2. 簡単なPHPスクリプトを動かしてみよう
  3. ファイルから1行ずつ読み込む - fgets()
  4. ユニークなファイル名の一時ファイルを作成 - tempnam()
  5. ヒアドキュメント

include_path を取得・設定 - get_include_path()、set_include_path()

当ページのリンクには広告が含まれています。

プログラミング言語PHPで、現在の include_path 設定を取得する関数 get_include_path()、include_path を設定する関数 set_include_path()を紹介します。

get_include_path関数

string get_include_path ( void )
現在設定されている include_path を取得します。
引数
引数はありません。
返り値
設定されている include_path を文字列で返します。

set_include_path関数

string set_include_path ( string $new_include_path )
引数に指定したパスを include_path に設定します。
引数
$new_include_path
include_path に設定するパスを指定します。
返り値
include_path の設定に成功した場合は、指定したパスを返します。
失敗して場合は、falseを返します。

サンプルコード

include_path を取得・設定するサンプルコードです。

get_include_path()
set_include_path( パス )
<?php
/* 現在の include_path を取得 */
var_dump( get_include_path() );

/* include_path を設定 */
set_include_path('/tmp');
var_dump( get_include_path() );
?>

実行結果です。

string(32) ".:/usr/share/pear:/usr/share/php"
string(4) "/tmp"

その他 の人気記事

  1. PHPの設定内容を確認する - phpinfo()
  2. メッセージを出力し、スクリプトを終了 - die()、exit()
  3. スクリプトを一時停止 - sleep()、usleep()

関連記事(一部広告含む)