max_execution_time only affect the execution time of the script itself.
Any time spent on activity that happens outside the execution of the script
such as system calls using system(), stream operations, database queries, etc.
is not included when determining the maximum time that the script has been running.
This is not true on Windows where the measured time is real.
Run Code Online (Sandbox Code Playgroud)
测试证实了这一点:
不会超时
<?php
set_time_limit(5);
$sql = mysqli_connect('localhost','root','root','mysql');
$query = "SELECT SLEEP(10) FROM mysql.user;";
$sql->query($query) or die($query.'<br />'.$sql->error);
echo "You …Run Code Online (Sandbox Code Playgroud) 我有一个简单的PHP函数,它应该在调用时执行Pyton脚本.我在我的php程序中多次尝试过这种函数,但不知怎的,这次函数根本没有执行python脚本.当我从命令提示符访问脚本并运行时,python testing.py它成功执行.有一件事我想提一下,这个脚本有一些严格的python的NLTK库实现,并且执行和执行它的操作需要20多秒(即数据处理和存储到db).执行中的延迟导致了这个问题,还是这次我还缺少其他的东西?
function success(){
$mystring = exec('python testing.py');
$mystring;
if(!$mystring){
echo "python exec failed";
}
else{
echo "<br />";
echo "successfully executed!";
}
Run Code Online (Sandbox Code Playgroud)