doudou130216 2016-05-26 09:19 采纳率: 0%
浏览 56
已采纳

for循环执行php代码错误

i'm using this function http://php.net/manual/en/function.getopt.php to do this

$options = getopt(array('c::'), array('chunk::'));
var_dump($options);

this code located in a file called do.php and i using this shell command to print the result

for i in `seq 2`;do php /home/user/public_html/do.php --chunk=$i ;done

the result is

array(2) {
  ["chunk"]=>
  string(1) "1"
}
array(2) {
  ["chunk"]=>
  string(1) "1"
}

how that happend? it should

array(2) {
  ["chunk"]=>
  string(1) "1"
}
array(2) {
  ["chunk"]=>
  string(1) "2"
}

(PHP VERSION 5.4.45)

  • 写回答

1条回答 默认 最新

  • douluan8828 2016-05-26 11:08
    关注

    As you can see in the documentation, the description of getopt is:

    array getopt ( string $options [, array $longopts ] )
    

    So the first parameter must be a string instead an array:

    <?php
    $options = getopt('c::', array('chunk::'));
    var_dump($options);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探