Php 当从mysql请求多条记录时,ob\u开始文件\u放置\u内容超时
这是我的密码Php 当从mysql请求多条记录时,ob\u开始文件\u放置\u内容超时,php,ob-start,file-put-contents,Php,Ob Start,File Put Contents,这是我的密码 <?php ini_set("default_socket_timeout", 60); include("include/dbcommon.php"); ob_start(); include("inspections_print.php"); $page_content = ob_get_contents(); ob_end_clean(); file_put_contents('files/bobby3.html',$page_content); ?> p
<?php
ini_set("default_socket_timeout", 60);
include("include/dbcommon.php");
ob_start();
include("inspections_print.php");
$page_content = ob_get_contents();
ob_end_clean();
file_put_contents('files/bobby3.html',$page_content);
?>
php请求从mysql数据库记录并生成报告。如果它只请求1条记录,它将工作并创建bobby3.html文件;如果我请求10条记录,它将创建一个空的bobby3.html文件。这是在我完全控制的Linode服务器上实现的。它被设置为使用
1024M
内存max\u execution\u time
=300和default\u socket\u timeout
=300您应该延长超时时间或删除行ini\u集(“default\u socket\u timeout”,60)在php文件上,因为配置已设置为300秒,如上所述。@Shudmeyer为什么超时很重要?如果脚本因超时而停止,它将根本不会创建bobby3.html
,也不会创建空文件。@Barmar,是的,它将创建空文件而不是内容。我们不知道在inspections_print.php(10条记录)上所涉及的查询是什么,这会导致执行时间过长,当它这样做时,bobby3.html的内容将变为空,因为timeout设置为60秒。我发现问题是javascript生成的分页符,检查_print.php从另一个文件中包括该分页符,因为它在2条记录上分页符,并且只有2条记录在bobby3.html中放置了一些js文件调用。