PHP Doku:: Example that shows the effect of scream - scream.examples-simple.html

Verlauf / Chronik / History: (4) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDas Verhalten von PHP beeinflussenBreak the silence operatorBeispieleExample that shows the effect of scream

Ein Service von Reinhard Neidl - Webprogrammierung.

Beispiele

<<Beispiele

Windows Cache for PHP>>

Example that shows the effect of scream

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

Beispiel #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/another-not-existing-file''r');
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

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

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

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


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)