How is it possible to set an infinite execution time for PHP script?
How is it possible to set an infinite execution time for PHP script?
To set an infinite execution time for a PHP script, you can use the set_time_limit()
function or the max_execution_time
directive in the php.ini
configuration file. Here are the details for both methods:
set_time_limit()
FunctionThe set_time_limit()
function allows you to specify the maximum execution time of a script in seconds. By passing 0
as the argument, you can set the execution time to be unlimited.
<?php
// Set the maximum execution time to unlimited
set_time_limit(0);
// Your long-running script here
while (true) {
// Simulate a long-running process
echo "Running...\n";
sleep(1);
}
?>
php.ini
ConfigurationYou can also set the max_execution_time
directive in the php.ini
file to 0
to allow scripts to run indefinitely. This change will apply to all PHP scripts running on the server.
php.ini
file...junior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào