命令行下 PHP 执行会楞一下
我用的 PHP 是 5.2.13 版本的,
在 Apache 下运行很快,
就是打开 cmd 命令提示符执行时,会莫名其妙的‘发呆’一下(大约五秒钟的样子)
如一个简单的文件a.php:
<?php echo "hello";
在命令行执行 >php a.php ,大约过一秒钟,看见字符串输出,然后又过了四秒钟,程序结束。
在 php.ini 里去掉扩展 php_curl.dll 时,发现速度又变飞快(回车一按好,程序就已经执行完毕了)
不知道大家有没有碰到过这个现象,我的系统是 win7 64 位的,
因为线上的 PHP 版本是 5.2.14 的,我特地选了个版本相近的(当时下载PHP时,没有找到 5.2.14的。。。)作为本地开发环境用。
回复讨论(解决方案)
这个问题倒不是很严重,就是有时候想写一段简单的代码,在命令行下调试,每次执行都楞个五秒钟,挺纠心的。就是好奇,系统,程序,配置照理说都没有问题啊,反而 Apache 里运行速度倒是挺快的。。。
php 运行时 需要加载 php5ts.dll 以及 php.ini 中指示的所有扩展库和相应的支撑库,这个加载是需要时间的
由于你是命令行执行的,所以当 php.exe 退出时,所有加载的动态链接库都会随之卸载
而 Apache 下就不同,由于 http.exe 没有退出,加载的动态链接库也不会卸载
两比之下自然是 Apache 下快啦
你加载的库多,所以就慢了。
原因见楼上。
google了一下,貌似这还真是一个 bug
https://bugs.php.net/bug.php?id=50410
php 运行时 需要加载 php5ts.dll 以及 php.ini 中指示的所有扩展库和相应的支撑库,这个加载是需要时间的
由于你是命令行执行的,所以当 php.exe 退出时,所有加载的动态链接库都会随之卸载
而 Apache 下就不同,由于 http.exe 没有退出,加载的动态链接库也不会卸载
两比之下自然是 Apache 下快啦
因为我不加载 php_curl.dll 这一个扩展,速度就扛扛的,所以我想应该不是加载库太多造成的。。。
你生产环境是windows么,如果你生产环境是linux,其实你在本地可以用虚拟机来搭环境。现在用vagrant或者boot2docker这些非常方便,而且也不用给virtualbox分多少内存。
你生产环境是windows么,如果你生产环境是linux,其实你在本地可以用虚拟机来搭环境。现在用vagrant或者boot2docker这些非常方便,而且也不用给virtualbox分多少内存。
我是 win7 64位旗舰版, 你说的软件我听都没听说过
google了一下,貌似这还真是一个 bug
https://bugs.php.net/bug.php?id=50410
多少根这个有关了:
It seems to only affect PHP 5.2.11 and 5.2.12, as I wasn't able to reproduce it with 5.2.10 using the exact same php.ini file.
Confirmed on Windows 7 and XP.
google了一下,貌似这还真是一个 bug
https://bugs.php.net/bug.php?id=50410
多少根这个有关了:
It seems to only affect PHP 5.2.11 and 5.2.12, as I wasn't able to reproduce it with 5.2.10 using the exact same php.ini file.
Confirmed on Windows 7 and XP.
嗯,上面的描述和我遇到的情况很像,看来是 PHP 本身的问题,不管它了。。。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

The enumeration function in PHP8.1 enhances the clarity and type safety of the code by defining named constants. 1) Enumerations can be integers, strings or objects, improving code readability and type safety. 2) Enumeration is based on class and supports object-oriented features such as traversal and reflection. 3) Enumeration can be used for comparison and assignment to ensure type safety. 4) Enumeration supports adding methods to implement complex logic. 5) Strict type checking and error handling can avoid common errors. 6) Enumeration reduces magic value and improves maintainability, but pay attention to performance optimization.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.
