开发者

Is there a performance difference between running a PHP script via CLI and via webserver?

Is it different to run a php script using e.g., /usr/sbin/php myscript.php

or using a web server e.g., http://127.0.0.1/myscript.php?

By "different" I refer to the time of the开发者_如何学C response; who wins?


Could be both.

The former because: There is no webserver + http + tcp overhead.

The latter because: The PHP process may already be started (FastCGI).

Thus: Don't guess, profile!


Yes, they're different. You don't have a web server environment wrapped around the command line version, so many values in $_SERVER will be absent/different, and the web-related super-globals will be empty.

As well, command line may be faster than the web version, as you don't have the TCP/IP and HTTP overhead to deal with, but that all depends on how the command line PHP is configured versus the in-server version. The command line version could be loading hundreds of extra modules, while the web version is a stripped down/lean/mean installation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜