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

HOTTA Michihide hotta @ net-newbie.com
2008年 7月 24日 (木) 22:57:25 JST


堀田@長崎市です。

From: kaz <okui @ sannet.ne.jp>
To: php-users @ php.gr.jp
Date: Thu, 24 Jul 2008 22:14:36 +0900
Subject: [PHP-users 33879] PHP をシェルスクリプトとして使用する場合

> require_once( "../config.php" );を使う為にはどうすればいいんで
> しょうか?
> コマンドラインでは使えない仕様なら仕方ありませんが。

使えないということはないはずだと思い、試してみました。

m-hotta @ note:~/test/sub$ php -v|head -1
PHP 5.2.5 (cli) (built: Mar  1 2008 11:52:22)
m-hotta @ note:~/test/sub$ ls
a.php
m-hotta @ note:~/test/sub$ cat a.php
#!/usr/bin/php
<?php
ini_set('include_path', '.');
printf("current include_path = %s\n", ini_get('include_path'));
require_once('../config.php');
?>
m-hotta @ note:~/test/sub$ ls ..
config.php  sub
m-hotta @ note:~/test/sub$ cat ../config.php
<?php print("This is config.php\n"); ?>
m-hotta @ note:~/test/sub$ ./a.php
current include_path = .
This is config.php

手元の環境では、使えました。

あとは、php.ini の safe_mode* を調べてみるとか?

-- 
HOTTA Michihide <hotta @ net-newbie.com>


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