douyalin2258 2017-03-24 05:32
浏览 84

PHP exec()函数加速

I am using the exec() function in PHP to run a command via command prompt. However the time which is needed to process this command using PHP is much longer compared to when I actually run the command on the CLI.

Any idea how I can improve its performance or make more efficient calls? I am trying to run powershell scripts.

  • 写回答

1条回答 默认 最新

  • dtz30833 2017-03-24 05:46
    关注

    The exec() function needs to create another process, a virtual shell, run the command, wait for the reply, and then return with the results, if any.

    That’s the sort of thing you can expect whenever you want PHP, or some other platform, to communicate outside of itself.

    There are the following alternatives:

    • Simple shell commands have corresponding PHP functions. This includes basic file manipulation.
    • If you’re using exec to call another program, such as ImageMagick, there may be an interface available to PHP directly.
    • There may be alternative PHP scripts available to do the same job as a command line process.

    Other than that, maybe not.

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)