Skip to content

Instantly share code, notes, and snippets.

@AllenJB
Created February 14, 2020 08: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 AllenJB/fd2fdea2ff3cbab7cbf74463f0650994 to your computer and use it in GitHub Desktop.
Save AllenJB/fd2fdea2ff3cbab7cbf74463f0650994 to your computer and use it in GitHub Desktop.
PHP Intentional Error Tests
public function fatalMemory() : void
{
$a = '';
while (true) {
$a .= str_repeat("Hello", 1024 * 1024);
}
}
public function timeout() : void
{
$tsLimit = time() + 120;
while (time() < $tsLimit) {
// Do nothing;
$v = file_get_contents(PROJECT_ROOT . "composer.json");
}
print "Timeout!\n";
}
public function timeoutIgnoreAbort() : void
{
ignore_user_abort(true);
set_time_limit(1);
$tsLimit = time() + 5;
while (time() < $tsLimit) {
// Do nothing;
$v = file_get_contents(PROJECT_ROOT . "composer.json");
}
print "Timeout!\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment