Strange 5 second pause with PHP command line inter

2019-02-13 13:50发布

I'm getting a strange 5 to 7 second pause when executing PHP scripts from the command-line PHP client (PHP 5.2 on Windows).

During this pause the PHP script just appears to 'freeze' for a while before returning to the command prompt. It is not using any significant CPU time, it's like it is waiting for some delay.

After experimenting with PHP.ini, I've narrowed this down to the fact that the mysql or mysqli extension is enabled. If these extensions are both disabled, no annoying pause and the PHP script terminates in mere milliseconds.

The command I'm using is:

"C:\Program Files\PHP\php.exe" -f %1

Where %1 is the PHP script.

The pause still occurs even if the PHP script being executed is essentially empty:

<?php

?>

Do you know what is causing this pause and how I can remove it while still allowing mysql or mysqli support for PHP on the command line?

3条回答
看我几分像从前
2楼-- · 2019-02-13 14:26

I also experienced an annoying 2 second delay running PHP from the command line under Windows 7 64bit.

This version had a delay:
php.exe (v5.3.5) shipped with ZendServer Community Edition

This version was wonderfully quick:
php.exe (v5.3.6) shipped with EasyPHP

(Sorry to bump an ancient thread, but hopefully this helps others Googling this issue.)

查看更多
3楼-- · 2019-02-13 14:35

For me (Zend Server CE on Mac OS X), the imap exetension was the culprit. Disabling it solved the problem.

Anoyone wants to write a PHP extension bisecting script? :)

查看更多
▲ chillily
4楼-- · 2019-02-13 14:45

it's a bug in mysql. you can solve it by getting the latest libmysql.dll (5.1.31 or higher. some older versions also work - see second link). make sure that's the libmysql.dll actually used and there are no other libmysql.dlls in your path. see the related php issue for details.

查看更多
登录 后发表回答