2009-02-26 22:23:44 +00:00
<?xml version="1.0" encoding="utf-8"?>
2009-07-11 08:48:51 +00:00
<!-- $Revision$ -->
2009-02-26 22:23:44 +00:00
<chapter xml:id= "scream.examples" xmlns= "http://docbook.org/ns/docbook" xmlns:xlink= "http://www.w3.org/1999/xlink" >
&reftitle.examples;
2011-09-30 14:21:51 +00:00
<section xml:id= "scream.examples-simple" >
2009-02-26 22:23:44 +00:00
<title > Example that shows the effect of scream</title>
<para >
This example demonstrates how scream affects the behaviour of PHP's error handler.
</para>
<para >
<example >
<title > Enabling and disabling scream at runtime</title>
<programlisting role= "php" >
< ![CDATA[
< ?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');
?>
]]>
</programlisting>
&example.outputs.similar;
<screen >
< ![CDATA[
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
]]>
</screen>
</example>
</para>
<note >
<simpara >
2009-02-26 23:45:40 +00:00
Usually one would set this in the <link linkend= "configuration.file" > php.ini configuration file</link>
2009-02-26 22:23:44 +00:00
instead of changing the code.
</simpara>
</note>
</section>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
2009-09-25 07:04:39 +00:00
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
2009-02-26 22:23:44 +00:00
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->