Skip to content

Instantly share code, notes, and snippets.

@kocsismate
Last active December 21, 2020 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kocsismate/dbcc4ba81b27cfb2e25b949723bb7c79 to your computer and use it in GitHub Desktop.
Save kocsismate/dbcc4ba81b27cfb2e25b949723bb7c79 to your computer and use it in GitHub Desktop.
Examples when https://wiki.php.net/rfc/max_execution_wall_time would be useful
<?php
sleep(3);
<?php
ini_set("max_execution_time", 10);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/index.php");
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
for ($i = 0; $i < 100; $i++) {
curl_exec($ch);
echo curl_error($ch);
}
// This script will run for more than 100 seconds, even though max_execution_time is 10 seconds
<?php
ini_set("error_reporting", E_ALL);
ini_set("display_errors", 1);
ini_set("max_execution_time", 10);
ini_set("default_socket_timeout", 1);
for ($i = 0; $i < 100; $i++) {
echo "Iteration $i\n";
file_get_contents("http://localhost/index.php");
echo "\n----------------\n";
}
// This script will run for more than 100 seconds, even though max_execution_time is 10 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment