set_time_limit测试代码如下:
测试结果:
486206
486207
486208
Fatal error: Maximum execution time of 1 second exceeded in E:/Server/localhost/test/1.php on line 4
说明循环到 486209 的时候,脚本已经运行超过1秒,所以提示超时
友情提示:千万不要在设置的秒数限制较多的情况下运行这个脚本!
memory_limit测试代码如下:
1.sql是大小是2M,错误提示如下:
Fatal error: Allowed memory size of 1048576 bytes exhausted (tried to allocate 2047672 bytes)
本文通过设置PHP的执行时间和内存限制,演示了如何控制脚本的执行资源消耗,包括设置最大执行时间导致的超时错误和内存限制导致的资源耗尽错误。
1317

被折叠的 条评论
为什么被折叠?



