sto*_*ofl 1 php command-line-interface
我无法在我的mac上运行auto_prepend_file:
# cat /opt/local/lib/php/test.php
<?php
function test() { return 'foo'; }
# php --ini | grep php.ini
Configuration File (php.ini) Path: /opt/local/etc/php5
Loaded Configuration File: /opt/local/etc/php5/php.ini
# cat /opt/local/etc/php5/php.ini | grep auto_prepend_file
auto_prepend_file = "/opt/local/lib/php/test.php"
# ls -la /opt/local/etc/php5/php.ini
-rw-r--r-- 1 root admin 68630 Jul 27 13:53 /opt/local/etc/php5/php.ini
# php -r "echo ini_get('auto_prepend_file');"
/opt/local/lib/php/test.php
Run Code Online (Sandbox Code Playgroud)
但是之后...
# php -r "echo test();"
Fatal error: Call to undefined function test() in Command line code on line 1
# php -i | grep auto_prepend_file
auto_prepend_file => /opt/local/lib/php/test.php => /opt/local/lib/php/test.php
Run Code Online (Sandbox Code Playgroud)
它通过(重新启动)apache工作.
你知道我错了什么吗?
auto_prepend_file直接通过-r命令行开关运行代码时不执行.无论PHP本身是从CLI调用还是在可执行文件的shebang中指定,它都可以在命令行上执行PHP文件时正常工作.
| 归档时间: |
|
| 查看次数: |
2616 次 |
| 最近记录: |