Example that shows the effect of scream

This example demonstrates how scream affects the behaviour of PHP's error handler.

Example #1 Enabling and disabling scream at runtime

<?php
// Make sure errors will be shown
ini_set('display_errors'true);
error_reporting(E_ALL);

// Disable scream - this is the default and produce an error
ini_set('scream.enabled'false);
echo 
"Opening http://example.com/not-existing-file\n";
@
fopen('http://example.com/not-existing-file''r');

// Now enable scream and try again
ini_set('scream.enabled'true);
echo 
"Opening http://example.com/not-existing-file\n";
@
fopen('http://example.com/not-existing-file''r');
?>

以上例程的输出类似于:

Opening http://example.com/not-existing-file
Opening http://example.com/not-existing-file

Warning: fopen(http://example.com/not-existing-file): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in example.php on line 14

Note: Usually one would set this in the php.ini configuration file instead of changing the code.

相关文章
php deque returns a representation that can be converted to jsonphp eventhttp sets default callback to handle requests that are not caught by specific callbacksphp imap 函数 returns all imap alert messages that have occurredphp imap 函数 returns the list of mailboxes that matches the given textphp variable handling 函数 verify that the contents of a variable is a countable valuephp sodium 函数 verifies that a password matches a hashphp imagick changes the color value of any pixel that matches targetphp 范例 example that implements inclued into an applicationphp intlcalendar whether this objectʼs time is after that of the passed objectphp intlcalendar whether this objectʼs time is before that of the passed objectphp mongocommandcursor checks if there are results that have not yet been sent from the databasephp mongodb bson javascript returns a representation that can be converted to jsonphp mongodb bson objectid returns a representation that can be converted to jsonphp mongodb driver manager execute a database command that readsphp mongodb driver server execute a database command that reads and writes on this serverphp mongodb driver server execute a database command that writes on this serverphp phar defines a list of up to 4 $ server variables that should be modified for executionphp 范例 example that shows the effect of screamphp solrquery returns the maximum number of constraint counts that should be returned for the facet fieldsphp weakref acquires a strong reference on that object
关注编程学问公众号