Câu hỏi phỏng vấn PHP
Câu hỏi

How is it possible to set an infinite execution time for PHP script?

Câu trả lời

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:

Using set_time_limit() Function

The 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 Copy
<?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);
}
?>

Using php.ini Configuration

You 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.

  1. Open your php.ini file...
junior

junior

Gợi ý câu hỏi phỏng vấn

junior

Differentiate between echo and print()

middle

Differentiate between parameterised and non parameterised functions

expert

Are PDO prepared statements sufficient to prevent SQL injection?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào