【问题标题】:Variables in shell_exec() scriptshell_exec() 脚本中的变量
【发布时间】:2011-10-17 23:11:43
【问题描述】:

有没有办法让这个简单的脚本正常运行?

<?php
$hi = "echo hi";
shell_exec($hi);
echo "<pre>$output</pre>";
?>

请帮帮我?

【问题讨论】:

  • 不应该将shell_exec($hi); 改为$output = shell_exec($hi);
  • thx,我一定是不小心删了东西,原来是这样

标签: php shell variables


【解决方案1】:

当然只是分配变量。

<?php
$hi = "echo hi";
$output = shell_exec($hi);
echo "<pre>$output</pre>";
?>

【讨论】:

    【解决方案2】:
    $hi = "echo hi";
    # the result needs to be assigned to $output before using it
    $output = shell_exec($hi);
    echo "<pre>$output</pre>";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-26
      • 1970-01-01
      • 2015-06-25
      • 2016-07-16
      • 2010-12-29
      • 2013-10-30
      • 1970-01-01
      相关资源
      最近更新 更多