【问题标题】:Executing php on the background not happening when passing arguments传递参数时不会在后台执行php
【发布时间】:2014-02-26 19:36:01
【问题描述】:

我正在尝试使用这行代码在后台执行一个 php:

echo exec("echo 'php -q file.php abcd' | at now 2>&1", $result);

只要我在 file.php 中不需要代码点火器,它就可以很好地传递参数:

ob_start();
require_once('/path_to_code_igniter/index.php'); 
ob_end_clean();

当我包含代码点火器时,脚本停止工作。我可以让它工作的唯一方法是删除参数,所以如果我运行:

echo exec("echo 'php -q file.php' | at now 2>&1", $result);

它适用于代码点火器要求。错误日志没有给出任何错误。 它只显示 warning: commands will be executed using /bin/sh job 148 at Wed Feb 26 16:02:00 2014

谁能指点我一个方向(我被困在这个方向好几天了)?

【问题讨论】:

  • 你不想在里面回声
  • 实际上现在它给了我未定义的变量:argv

标签: php exec command-line-interface


【解决方案1】:

我做错了。 Codeigniter 有一个通过 PHP CLI 调用控制器的简单教程: http://ellislab.com/codeigniter/user-guide/general/cli.html

我猜我在外部加载 Codeigniter 的方式不正确,所以当我通过 CLI 传递参数时会弄乱我的脚本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 2018-06-07
    相关资源
    最近更新 更多