超出错误 60 秒的最长执行时间

2022-08-30 19:34:13

我收到以下错误消息:

警告:file_get_contents(http://localhost/sample_pie.php) [function.file-get-content]:无法打开流:连接尝试失败,因为连接的一方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应。在 C:\xampp\htdocs\EXACT\report 中.php第 206 行

致命错误:在第 206 行的 C:\xampp\htdocs\EXACT\report.php 中超过了 60 秒的最大执行时间

下面是第 206 行:

$url = 'http://localhost/sample_pie.php';
$img = 'C:\xampp\htdocs\piechart.jpg';
file_put_contents($img, file_get_contents($url));

我必须做些什么来解决这个问题?


答案 1

您的脚本执行了 60 多秒,但已终止。php 中有一个值.ini定义了 PHP 脚本可以运行的最长时间。这样做的目的是防止脚本挂起。您可以尝试优化脚本,但如果它打算运行很长时间,则可以更新值(称为 )。max_execution_time

您也可以尝试通过运行set_time_limit()函数来更改特定脚本的此值,此处的文档


答案 2

max_input_time也可能导致相同的错误。


推荐