0
我使用這個功能http://php.net/manual/en/function.getopt.php做到這一點for循環EXCUTE一個PHP代碼錯誤
$options = getopt(array('c::'), array('chunk::'));
var_dump($options);
這段代碼位於一個名爲do.php並使用該shell命令打印結果
我for i in `seq 2`;do php /home/user/public_html/do.php --chunk=$i ;done
結果是
array(2) {
["chunk"]=>
string(1) "1"
}
array(2) {
["chunk"]=>
string(1) "1"
}
怎麼說happend?應該
array(2) {
["chunk"]=>
string(1) "1"
}
array(2) {
["chunk"]=>
string(1) "2"
}
(PHP版本5.4.45)
第一個參數o f getopt應該是一個字符串而不是數組。 使用php的絕對路徑。將數組('c ::')轉換爲'c ::'後,代碼在我的設置中工作得很好 –