2012-06-04 118 views
1

這對我來說很奇怪。我想知道爲什麼。我寫了一個PHP腳本來驗證test.php的在PHP shell腳本和MAMP上的PHP之間的區別?

<?php 
    print("Hello World"); 
    ?> 

的驗證腳本的index.php另一個名爲PHP腳本的語法是:

#!/usr/bin/env php 
<?php 
exec("php -l test.php", $error, $retcode); 
echo($retcode . "<br />"); 
var_dump($error); 
?> 

當我在命令行運行PHP index.php,它生成此輸出:

0<br />array(1) { 
    [0]=> 
    string(37) "No syntax errors detected in test.php" 
} 

這對我來說很好。但是,當我在本地主機上運行時,它會生成此輸出:

#!/usr/bin/env php 5 
array(0) { } 

爲什麼$ retcode設置爲5?另外,我在PHP5.3上

+0

你在哪裏得到$ RETCODE是設爲五?我沒有看到你的例子。 –

+0

我已經包含了輸出屏幕。 5位於#!/ usr/bin/env php旁邊 – knd

回答

0

好的,我已經知道了這一點。

檢查http://linux.die.net/man/1/rsync退出代碼信息。

的問題是,我必須使用對MAMP PHP解釋,那就是:

exec("/Applications/MAMP/bin/php/php5.3.6/bin/php -l $file",$error,$retcode); 

我使用之前是PHP解釋器在OS X上的一個

相關問題