[PHP-users 33880] Re: PHP をシェルスクリプトとして使用する場合

Sotaro OMURA omura @ tapweb.co.jp
2008年 7月 24日 (木) 22:21:59 JST


大村と申します。

こんな感じでどうでしょうか。
require_once dirname(__FILE__).'/../config.php';

kaz さんは書きました:
> こんばんは、奥井です。
> PHP をコマンドラインから使用した場合、require_onceが動作しません。
> test.phpでひとつ上の階層にあるファイルをrequireするとrequire_onceのところでPHP Fatal error:  main(): Failed opening required '../config.php' (include_path='.:/usr/share/php4-pear') 
> ../config.phpをフルパスで書いたらエラーになりません。
> test.php
> #!/usr/bin/php
> <?php
> 	require_once( "../config.php" );
> 
> ?>
> require_once( "../config.php" );を使う為にはどうすればいいんでしょうか?
> コマンドラインでは使えない仕様なら仕方ありませんが。
> ご教授お願いします。


PHP-users メーリングリストの案内