cvs: presentations / errorhandling-adam2003.xml /slides/errorhandling 404s.png 991202fail2.jpg bug.gif cannot-connect.xml display-errors.xml
error-reporting.xml error.jpg fallback-to-cache.xml funny-404s.xml handle-errors.xml landonize.png log-errors.xml miscalculation.xml monkey_typing.jpg
mysql-error-cache.png mysql-error-handle.png mysql-error.png normal404.png qmark.png questions.xml rasmus-trick.xml redir-404.xml resources.xml
search-404.xml semantical.xml standard-404.xml style.css syntactical.xml test.jpg ws.png
| From: | Derick Rethans | Date: | Tue, 06 May 2003 20:51:46 +0000 |
| Subject: | cvs: presentations / errorhandling-adam2003.xml /slides/errorhandling 404s.png 991202fail2.jpg bug.gif cannot-connect.xml display-errors.xml error-reporting.xml error.jpg fallback-to-cache.xml funny-404s.xml handle-errors.xml landonize.png log-errors.xml miscalculation.xml monkey_typing.jpg mysql-error-cache.png mysql-error-handle.png mysql-error.png normal404.png qmark.png questions.xml rasmus-trick.xml redir-404.xml resources.xml search-404.xml semantical.xml standard-404.xml style.css syntactical.xml test.jpg ws.png |
||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-696@lists.php.net to get a copy of this message | ||
derick Tue May 6 16:51:46 2003 EDT
Added files:
/presentations errorhandling-adam2003.xml
/presentations/slides/errorhandling 404s.png 991202fail2.jpg
bug.gif cannot-connect.xml
display-errors.xml
error-reporting.xml error.jpg
fallback-to-cache.xml
funny-404s.xml
handle-errors.xml landonize.png
log-errors.xml
miscalculation.xml
monkey_typing.jpg
mysql-error-cache.png
mysql-error-handle.png
mysql-error.png normal404.png
qmark.png questions.xml
rasmus-trick.xml redir-404.xml
resources.xml search-404.xml
semantical.xml standard-404.xml
style.css syntactical.xml
test.jpg ws.png
Log:
- First part of error_handling
Index: presentations/errorhandling-adam2003.xml +++ presentations/errorhandling-adam2003.xml <presentation template="php" navmode="html" navbarbackground="#3C5BB4" stylesheet="presentations/slides/errorhandling/style.css" backgroundfixed="1" > <topic>PHP</topic> <title>Error Handling</title> <event>International PHP Conference Amsterdam</event> <location>Amsterdam, the Netherlands</location> <date>May 9th, 2003</date> <speaker>Derick Rethans</speaker> <email>d.rethans@jdimedia.nl</email> <url>http://pres.derickrethans.nl/errorhandling</url> <slide>slides/ze-xdebug/title.xml</slide> <!-- 404 errors and handling there off --> <slide>slides/errorhandling/standard-404.xml</slide> <slide>slides/errorhandling/funny-404s.xml</slide> <slide>slides/errorhandling/redir-404.xml</slide> <slide>slides/errorhandling/search-404.xml</slide> <slide>slides/errorhandling/rasmus-trick.xml</slide> <!-- Database connection problems / other server side problems --> <slide>slides/errorhandling/cannot-connect.xml</slide> <slide>slides/errorhandling/handle-errors.xml</slide> <!-- PHP error control functions --> <slide>slides/errorhandling/error-reporting.xml</slide> <slide>slides/errorhandling/display-errors.xml</slide> <slide>slides/errorhandling/log-errors.xml</slide> <!-- Trick --> <slide>slides/errorhandling/fallback-to-cache.xml</slide> <!-- Preventing --> <slide>slides/errorhandling/user-input.xml</slide> <slide>slides/errorhandling/check-return-value.xml</slide> <!-- Dry theory --> <slide>slides/errorhandling/syntactical.xml</slide> <slide>slides/errorhandling/semantical.xml</slide> <slide>slides/errorhandling/miscalculation.xml</slide> <!-- Testing! --> <slide>slides/errorhandling/function-lib.xml</slide> <slide>slides/errorhandling/test-all-paths1.xml</slide> <slide>slides/errorhandling/test-all-paths2.xml</slide> <slide>slides/errorhandling/phpunit1.xml</slide> <slide>slides/errorhandling/phpunit2.xml</slide> <slide>slides/errorhandling/phpunit3.xml</slide> <slide>slides/errorhandling/phpunit4.xml</slide> <slide>slides/errorhandling/phpunit5.xml</slide> <!-- Still problems? Debug! --> <slide>slides/errorhandling/questions.xml</slide> <slide>slides/errorhandling/resources.xml</slide> </presentation> Index: presentations/slides/errorhandling/cannot-connect.xml +++ presentations/slides/errorhandling/cannot-connect.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Connection errors</title> <blurb> </blurb> <image align="center" filename="mysql-error.png" /> <blurb> </blurb> <list effect="slide" fontsize="4.5em"> <bullet>Yuck!</bullet> <bullet>Lose visitors</bullet> <bullet>Scare away potential customers</bullet> <bullet>*Unneeded*</bullet> </list> </slide> Index: presentations/slides/errorhandling/display-errors.xml +++ presentations/slides/errorhandling/display-errors.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Displaying errors</title> <list effect="slide" fontsize="4em"> <bullet>display_errors = On</bullet> <bullet>display_startup_errors = Off</bullet> <bullet>html_errors = On/Off</bullet> <bullet>error_prepend_string/error_append_string</bullet> <bullet>docref_root/docref_ext</bullet> </list> <example fontsize="1em">docref_root="http://landonize.it/?how=url&amp;theme=classic&amp; filter=Landon&amp;url=http%3A%2F%2Fwww.php.net%2F" docref_ext=""</example> <image align="center" filename="landonize.png" /> </slide> Index: presentations/slides/errorhandling/error-reporting.xml +++ presentations/slides/errorhandling/error-reporting.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Reporting Errors</title> <blurb> </blurb> <blurb> </blurb> <list effect="slide" fontsize="4em"> <bullet>php.ini: %error_reporting = |ff0000|E_ALL|%</bullet> <bullet>httpd.conf: %php_value error_reporting |ff0000|2047|%</bullet> <bullet>in script: %error_reporting(|ff0000|E_ALL & ~E_NOTICE|);%</bullet> </list> <blurb> </blurb> <list marginleft="3em" effect="slide" fontsize="3.5em" type="none"> <bullet>E_ALL == 2047</bullet> <bullet>E_NOTICE == 8</bullet> <bullet>E_ALL & ~E_NOTICE == 2039</bullet> </list> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <list fontsize="2em" effect="slide" type="none"> <bullet>http://www.php.net/manual/en/ref.errorfunc.php#errorfunc.constants</bullet> </list> </slide> Index: presentations/slides/errorhandling/fallback-to-cache.xml +++ presentations/slides/errorhandling/fallback-to-cache.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Fallback</title> <blurb> </blurb> <image align="center" filename="mysql-error-cache.png" /> <blurb> </blurb> <example fontsize="1.2em" filename="il-error-handle.php" result="0" /> <list effect="slide" fontsize="4.5em"> <bullet>Always check return values</bullet> <bullet>@ operator</bullet> </list> </slide> Index: presentations/slides/errorhandling/funny-404s.xml +++ presentations/slides/errorhandling/funny-404s.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>404 pages</title> <image align="center" filename="404s.png" /> <example fontsize="1em">ErrorDocument 404 /my404page.html</example> </slide> Index: presentations/slides/errorhandling/handle-errors.xml +++ presentations/slides/errorhandling/handle-errors.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Handle errors!</title> <blurb> </blurb> <image align="center" filename="mysql-error-handle.png" /> <blurb> </blurb> <example fontsize="1.2em"><![CDATA[<?php if (@mysql_connect('localhost', 'root', 'ut34FblY:')) { if (@mysql_select_db('game')) { $r = mysql_query('SELECT * FROM news ORDER BY date DESC LIMIT 1'); ...]]></example> <list effect="slide" fontsize="4.5em"> <bullet>Always check return values</bullet> <bullet>@ operator</bullet> </list> </slide> Index: presentations/slides/errorhandling/log-errors.xml +++ presentations/slides/errorhandling/log-errors.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Logging errors</title> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <list effect="slide" fontsize="6em"> <bullet>log_errors = On</bullet> <bullet>log_errors_max_len = 1024</bullet> <bullet>error_log = /var/log/phperrors</bullet> <bullet>error_log = syslog</bullet> </list> </slide> Index: presentations/slides/errorhandling/miscalculation.xml +++ presentations/slides/errorhandling/miscalculation.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Miscalculations</title> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <image align="left" filename="991202fail2.jpg" /> <example fontsize="1.4em"><![CDATA[<?php function course_correction($x, $y, $z, $speed) { if ($x * $x * $y * $y * $z > $speed) { $speed = $speed - 5; } return $speed; } $speed = 34; echo course_correction(2, 2, 2, $speed); ? >]]></example> <blurb>Output:</blurb> <example fontsize="1.4em">34</example> </slide> Index: presentations/slides/errorhandling/questions.xml +++ presentations/slides/errorhandling/questions.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Questions</title> <blurb></blurb> <image filename="qmark.png" align="center"/> </slide> Index: presentations/slides/errorhandling/rasmus-trick.xml +++ presentations/slides/errorhandling/rasmus-trick.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Rasmus' trick</title> <blurb fontsize="3em">Url: http://yoursite.com/news/000001.html</blurb> <blurb fontsize="3em">Set up a 404 error handler:</blurb> <example fontsize="1.5em"><![CDATA[<Directory /home/httpd/news> ErrorDocument 404 /generate-news.php </Directory>]]></example> <blurb> </blurb> <blurb fontsize="3em">generate-news.php:</blurb> <example fontsize="1em"><![CDATA[<?php $id = basename($_SERVER['REDIRECT_URL'], '.html'); /* Generate the HTML */ include "/home/httpd/news/generator.php"; $html = generate_html($data); /* Show the page */ echo $html; /* Store the page for later use */ $fp = fopen(sprintf("/home/httpd/news/%06d.html", $id), "w"); fputs($fp, $html); fclose($fp); ? >]]></example> </slide> Index: presentations/slides/errorhandling/redir-404.xml +++ presentations/slides/errorhandling/redir-404.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Redir on 404</title> <blurb> </blurb> <blurb> </blurb> <example fontsize="2em">ErrorDocument 404 /error.php</example> <blurb> </blurb> <example fontsize="1.5em"><![CDATA[<?php header("Location: http://example.com/"); ? >]]></example> <blurb> </blurb> <list effect="slide" fontsize="4em"> <bullet>Pro: Hides errors from users</bullet> <bullet>Pro: Easy to implement</bullet> <bullet>Con: Nobody knows what went wrong</bullet> <bullet>Con: Retyping of URL required on spelling errors</bullet> </list> </slide> Index: presentations/slides/errorhandling/resources.xml +++ presentations/slides/errorhandling/resources.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Resources</title> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <link fontsize="2em" marginleft="5em" leader="These Slides: " href="http://pres.derickrethans.nl/errorhandling" target="_new"/> <link fontsize="2em" marginleft="5em" leader="PHP: " href="http://www.php.net" target="_new"/> <link fontsize="2em" marginleft="5em" leader="PHPUnit: " href="http://pear.php.net/package-info.php?pacid=38" target="_new"/> <link fontsize="2em" marginleft="5em" leader="Xdebug: " href="http://xdebug.derickrethans.nl" target="_new"/> <link fontsize="2em" marginleft="5em" leader="404s: " href="http://www.plinko.net/404/" target="_new"/> </slide> Index: presentations/slides/errorhandling/search-404.xml +++ presentations/slides/errorhandling/search-404.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Search on 404</title> <blurb> </blurb> <blurb> </blurb> <example fontsize="2em">ErrorDocument 404 /search.php</example> <blurb> </blurb> <blurb fontsize="3em">search.php:</blurb> <example fontsize="1em"><![CDATA[<?php $search_string = basename($_SERVER['REQUEST_URI']); $filename = $_SERVER['DOCUMENT_ROOT'] . ltrim($_SERVER['REQUEST_URI'], '/'); ob_start(); ? > <html> <head><title><?php echo "Info about $search_string"; ?></title></head> <body> <?php echo "<h1>$search_string:</h1>\n"; ? > </body> <?php $data = ob_get_contents(); ob_clean(); echo $data."\n(In error handler, saved to $filename)"; $f = fopen($filename, "w"); fwrite($f, $data); fclose($f); ? > ]]></example> </slide> Index: presentations/slides/errorhandling/semantical.xml +++ presentations/slides/errorhandling/semantical.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Semantical Errors</title> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <image align="right" filename="bug.gif" /> <list effect="slide" fontsize="5em"> <bullet>Logical Errors</bullet> <bullet>Always on a production box</bullet> <bullet>Test code!</bullet> <bullet>Also called *bugs*</bullet> </list> </slide> Index: presentations/slides/errorhandling/standard-404.xml +++ presentations/slides/errorhandling/standard-404.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Standard 404 page</title> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <image align="center" filename="normal404.png" /> </slide> Index: presentations/slides/errorhandling/style.css +++ presentations/slides/errorhandling/style.css <style title="Default" type="text/css"> body { font-size: 12pt; margin-left:1.5em; margin-right:0em; margin-bottom:0em; } ul { padding-top: 20; padding-left: 100; } th.trace { font-family: arial; font-size: 12pt; } td.trace { font-family: arial; font-size: 12pt; } th.tracesml { font-family: arial; font-size: 9pt; } td.tracesml { font-family: arial; font-size: 9pt; } div.sticky { margin: 0; position: fixed; top: 0em; left: 0em; right: auto; bottom: auto; width: auto; } div.shadow { background: #777777; padding: 0.5em; } div.navbar { padding: 4; margin: 0; height: 6em; background-color: #3c5bb4; color: #3c5bb4; font-family: verdana, tahoma, arial, helvetica, sans-serif; z-index: 99; } div.emcode { background: #cccccc; border: thin solid #000000; padding: 0.5em; font-family: monospace; } div.output { font-family: monospace; background: #eeee33; border: thin solid #000000; padding: 0.5em; } table.index { background: #cccccc; border: thin dotted #000000; padding: 0.5em; font-family: monospace; } td.index { background: #cccccc; padding: 1em; font-family: monospace; } h1 { font-size: 2em; } p,li { font-size: 2.6em; } a { text-decoration: none; } a:hover { text-decoration: underline; } c2right { margin : 1em 1em 0 0; padding-left : 1%; padding-right : 1%; border-style : solid; border-top-width : 1px; border-right-width : 1px; border-bottom-width : 1px; border-left-width : 1px; border-right-color : inherit; border-left-color : inherit; width : 46%; float : right; } c2left { margin : 1em 1em 0 0; padding-left : 1%; padding-right : 1%; border-style : solid; border-top-width : 1px; border-right-width : 1px; border-bottom-width : 1px; border-left-width : 1px; border-right-color : inherit; border-left-color : inherit; width : 46%; float : left; } box { margin : 0 0 0 0; padding-left : 1%; padding-right : 1%; border-style : solid; border-top-width : 1px; border-right-width : 1px; border-bottom-width : 1px; border-left-width : 1px; border-right-color : inherit; border-left-color : inherit; float : left; } </style> Index: presentations/slides/errorhandling/syntactical.xml +++ presentations/slides/errorhandling/syntactical.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Syntactical Errors</title> <blurb> </blurb> <list fontsize="5em"> <bullet>Parse Errors</bullet> </list> <blurb><![CDATA[<br /> <table align='center' border='1' cellspacing='0'> <tr><td bgcolor='#ffbbbb' colspan="3"><b>Parse error</b>: parse error in <b>/home/httpd/html/test/parse.php</b> on line <b>3</b><br /> <tr><th bgcolor='#aaaaaa' colspan='3'>Call Stack</th></tr> <tr><th bgcolor='#cccccc'>#</th><th bgcolor='#cccccc'>Function</th><th bgcolor='#cccccc'>Location</th></tr> </table>]]></blurb> <list fontsize="5em"> <bullet>Never on a production box</bullet> <bullet>%php -l%</bullet> </list> <blurb> </blurb> <example fontsize="1.5em"><![CDATA[[derick@kossu test]$ php -l parse.php Parse error: parse error in parse.php on line 3]]></example> </slide>
Index: presentations/errorhandling-adam2003.xml +++ presentations/errorhandling-adam2003.xml <presentation template="php" navmode="html" navbarbackground="#3C5BB4" stylesheet="presentations/slides/errorhandling/style.css" backgroundfixed="1" > <topic>PHP</topic> <title>Error Handling</title> <event>International PHP Conference Amsterdam</event> <location>Amsterdam, the Netherlands</location> <date>May 9th, 2003</date> <speaker>Derick Rethans</speaker> <email>d.rethans@jdimedia.nl</email> <url>http://pres.derickrethans.nl/errorhandling</url> <slide>slides/ze-xdebug/title.xml</slide> <!-- 404 errors and handling there off --> <slide>slides/errorhandling/standard-404.xml</slide> <slide>slides/errorhandling/funny-404s.xml</slide> <slide>slides/errorhandling/redir-404.xml</slide> <slide>slides/errorhandling/search-404.xml</slide> <slide>slides/errorhandling/rasmus-trick.xml</slide> <!-- Database connection problems / other server side problems --> <slide>slides/errorhandling/cannot-connect.xml</slide> <slide>slides/errorhandling/handle-errors.xml</slide> <!-- PHP error control functions --> <slide>slides/errorhandling/error-reporting.xml</slide> <slide>slides/errorhandling/display-errors.xml</slide> <slide>slides/errorhandling/log-errors.xml</slide> <!-- Trick --> <slide>slides/errorhandling/fallback-to-cache.xml</slide> <!-- Preventing --> <slide>slides/errorhandling/user-input.xml</slide> <slide>slides/errorhandling/check-return-value.xml</slide> <!-- Dry theory --> <slide>slides/errorhandling/syntactical.xml</slide> <slide>slides/errorhandling/semantical.xml</slide> <slide>slides/errorhandling/miscalculation.xml</slide> <!-- Testing! --> <slide>slides/errorhandling/function-lib.xml</slide> <slide>slides/errorhandling/test-all-paths1.xml</slide> <slide>slides/errorhandling/test-all-paths2.xml</slide> <slide>slides/errorhandling/phpunit1.xml</slide> <slide>slides/errorhandling/phpunit2.xml</slide> <slide>slides/errorhandling/phpunit3.xml</slide> <slide>slides/errorhandling/phpunit4.xml</slide> <slide>slides/errorhandling/phpunit5.xml</slide> <!-- Still problems? Debug! --> <slide>slides/errorhandling/questions.xml</slide> <slide>slides/errorhandling/resources.xml</slide> </presentation> Index: presentations/slides/errorhandling/cannot-connect.xml +++ presentations/slides/errorhandling/cannot-connect.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Connection errors</title> <blurb> </blurb> <image align="center" filename="mysql-error.png" /> <blurb> </blurb> <list effect="slide" fontsize="4.5em"> <bullet>Yuck!</bullet> <bullet>Lose visitors</bullet> <bullet>Scare away potential customers</bullet> <bullet>*Unneeded*</bullet> </list> </slide> Index: presentations/slides/errorhandling/display-errors.xml +++ presentations/slides/errorhandling/display-errors.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Displaying errors</title> <list effect="slide" fontsize="4em"> <bullet>display_errors = On</bullet> <bullet>display_startup_errors = Off</bullet> <bullet>html_errors = On/Off</bullet> <bullet>error_prepend_string/error_append_string</bullet> <bullet>docref_root/docref_ext</bullet> </list> <example fontsize="1em">docref_root="http://landonize.it/?how=url&amp;theme=classic&amp; filter=Landon&amp;url=http%3A%2F%2Fwww.php.net%2F" docref_ext=""</example> <image align="center" filename="landonize.png" /> </slide> Index: presentations/slides/errorhandling/error-reporting.xml +++ presentations/slides/errorhandling/error-reporting.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Reporting Errors</title> <blurb> </blurb> <blurb> </blurb> <list effect="slide" fontsize="4em"> <bullet>php.ini: %error_reporting = |ff0000|E_ALL|%</bullet> <bullet>httpd.conf: %php_value error_reporting |ff0000|2047|%</bullet> <bullet>in script: %error_reporting(|ff0000|E_ALL & ~E_NOTICE|);%</bullet> </list> <blurb> </blurb> <list marginleft="3em" effect="slide" fontsize="3.5em" type="none"> <bullet>E_ALL == 2047</bullet> <bullet>E_NOTICE == 8</bullet> <bullet>E_ALL & ~E_NOTICE == 2039</bullet> </list> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <list fontsize="2em" effect="slide" type="none"> <bullet>http://www.php.net/manual/en/ref.errorfunc.php#errorfunc.constants</bullet> </list> </slide> Index: presentations/slides/errorhandling/fallback-to-cache.xml +++ presentations/slides/errorhandling/fallback-to-cache.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Fallback</title> <blurb> </blurb> <image align="center" filename="mysql-error-cache.png" /> <blurb> </blurb> <example fontsize="1.2em" filename="il-error-handle.php" result="0" /> <list effect="slide" fontsize="4.5em"> <bullet>Always check return values</bullet> <bullet>@ operator</bullet> </list> </slide> Index: presentations/slides/errorhandling/funny-404s.xml +++ presentations/slides/errorhandling/funny-404s.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>404 pages</title> <image align="center" filename="404s.png" /> <example fontsize="1em">ErrorDocument 404 /my404page.html</example> </slide> Index: presentations/slides/errorhandling/handle-errors.xml +++ presentations/slides/errorhandling/handle-errors.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Handle errors!</title> <blurb> </blurb> <image align="center" filename="mysql-error-handle.png" /> <blurb> </blurb> <example fontsize="1.2em"><![CDATA[<?php if (@mysql_connect('localhost', 'root', 'ut34FblY:')) { if (@mysql_select_db('game')) { $r = mysql_query('SELECT * FROM news ORDER BY date DESC LIMIT 1'); ...]]></example> <list effect="slide" fontsize="4.5em"> <bullet>Always check return values</bullet> <bullet>@ operator</bullet> </list> </slide> Index: presentations/slides/errorhandling/log-errors.xml +++ presentations/slides/errorhandling/log-errors.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Logging errors</title> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <list effect="slide" fontsize="6em"> <bullet>log_errors = On</bullet> <bullet>log_errors_max_len = 1024</bullet> <bullet>error_log = /var/log/phperrors</bullet> <bullet>error_log = syslog</bullet> </list> </slide> Index: presentations/slides/errorhandling/miscalculation.xml +++ presentations/slides/errorhandling/miscalculation.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Miscalculations</title> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <image align="left" filename="991202fail2.jpg" /> <example fontsize="1.4em"><![CDATA[<?php function course_correction($x, $y, $z, $speed) { if ($x * $x * $y * $y * $z > $speed) { $speed = $speed - 5; } return $speed; } $speed = 34; echo course_correction(2, 2, 2, $speed); ? >]]></example> <blurb>Output:</blurb> <example fontsize="1.4em">34</example> </slide> Index: presentations/slides/errorhandling/questions.xml +++ presentations/slides/errorhandling/questions.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Questions</title> <blurb></blurb> <image filename="qmark.png" align="center"/> </slide> Index: presentations/slides/errorhandling/rasmus-trick.xml +++ presentations/slides/errorhandling/rasmus-trick.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Rasmus' trick</title> <blurb fontsize="3em">Url: http://yoursite.com/news/000001.html</blurb> <blurb fontsize="3em">Set up a 404 error handler:</blurb> <example fontsize="1.5em"><![CDATA[<Directory /home/httpd/news> ErrorDocument 404 /generate-news.php </Directory>]]></example> <blurb> </blurb> <blurb fontsize="3em">generate-news.php:</blurb> <example fontsize="1em"><![CDATA[<?php $id = basename($_SERVER['REDIRECT_URL'], '.html'); /* Generate the HTML */ include "/home/httpd/news/generator.php"; $html = generate_html($data); /* Show the page */ echo $html; /* Store the page for later use */ $fp = fopen(sprintf("/home/httpd/news/%06d.html", $id), "w"); fputs($fp, $html); fclose($fp); ? >]]></example> </slide> Index: presentations/slides/errorhandling/redir-404.xml +++ presentations/slides/errorhandling/redir-404.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Redir on 404</title> <blurb> </blurb> <blurb> </blurb> <example fontsize="2em">ErrorDocument 404 /error.php</example> <blurb> </blurb> <example fontsize="1.5em"><![CDATA[<?php header("Location: http://example.com/"); ? >]]></example> <blurb> </blurb> <list effect="slide" fontsize="4em"> <bullet>Pro: Hides errors from users</bullet> <bullet>Pro: Easy to implement</bullet> <bullet>Con: Nobody knows what went wrong</bullet> <bullet>Con: Retyping of URL required on spelling errors</bullet> </list> </slide> Index: presentations/slides/errorhandling/resources.xml +++ presentations/slides/errorhandling/resources.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Resources</title> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <link fontsize="2em" marginleft="5em" leader="These Slides: " href="http://pres.derickrethans.nl/errorhandling" target="_new"/> <link fontsize="2em" marginleft="5em" leader="PHP: " href="http://www.php.net" target="_new"/> <link fontsize="2em" marginleft="5em" leader="PHPUnit: " href="http://pear.php.net/package-info.php?pacid=38" target="_new"/> <link fontsize="2em" marginleft="5em" leader="Xdebug: " href="http://xdebug.derickrethans.nl" target="_new"/> <link fontsize="2em" marginleft="5em" leader="404s: " href="http://www.plinko.net/404/" target="_new"/> </slide> Index: presentations/slides/errorhandling/search-404.xml +++ presentations/slides/errorhandling/search-404.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Search on 404</title> <blurb> </blurb> <blurb> </blurb> <example fontsize="2em">ErrorDocument 404 /search.php</example> <blurb> </blurb> <blurb fontsize="3em">search.php:</blurb> <example fontsize="1em"><![CDATA[<?php $search_string = basename($_SERVER['REQUEST_URI']); $filename = $_SERVER['DOCUMENT_ROOT'] . ltrim($_SERVER['REQUEST_URI'], '/'); ob_start(); ? > <html> <head><title><?php echo "Info about $search_string"; ?></title></head> <body> <?php echo "<h1>$search_string:</h1>\n"; ? > </body> <?php $data = ob_get_contents(); ob_clean(); echo $data."\n(In error handler, saved to $filename)"; $f = fopen($filename, "w"); fwrite($f, $data); fclose($f); ? > ]]></example> </slide> Index: presentations/slides/errorhandling/semantical.xml +++ presentations/slides/errorhandling/semantical.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Semantical Errors</title> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <image align="right" filename="bug.gif" /> <list effect="slide" fontsize="5em"> <bullet>Logical Errors</bullet> <bullet>Always on a production box</bullet> <bullet>Test code!</bullet> <bullet>Also called *bugs*</bullet> </list> </slide> Index: presentations/slides/errorhandling/standard-404.xml +++ presentations/slides/errorhandling/standard-404.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Standard 404 page</title> <blurb> </blurb> <blurb> </blurb> <blurb> </blurb> <image align="center" filename="normal404.png" /> </slide> Index: presentations/slides/errorhandling/style.css +++ presentations/slides/errorhandling/style.css <style title="Default" type="text/css"> body { font-size: 12pt; margin-left:1.5em; margin-right:0em; margin-bottom:0em; } ul { padding-top: 20; padding-left: 100; } th.trace { font-family: arial; font-size: 12pt; } td.trace { font-family: arial; font-size: 12pt; } th.tracesml { font-family: arial; font-size: 9pt; } td.tracesml { font-family: arial; font-size: 9pt; } div.sticky { margin: 0; position: fixed; top: 0em; left: 0em; right: auto; bottom: auto; width: auto; } div.shadow { background: #777777; padding: 0.5em; } div.navbar { padding: 4; margin: 0; height: 6em; background-color: #3c5bb4; color: #3c5bb4; font-family: verdana, tahoma, arial, helvetica, sans-serif; z-index: 99; } div.emcode { background: #cccccc; border: thin solid #000000; padding: 0.5em; font-family: monospace; } div.output { font-family: monospace; background: #eeee33; border: thin solid #000000; padding: 0.5em; } table.index { background: #cccccc; border: thin dotted #000000; padding: 0.5em; font-family: monospace; } td.index { background: #cccccc; padding: 1em; font-family: monospace; } h1 { font-size: 2em; } p,li { font-size: 2.6em; } a { text-decoration: none; } a:hover { text-decoration: underline; } c2right { margin : 1em 1em 0 0; padding-left : 1%; padding-right : 1%; border-style : solid; border-top-width : 1px; border-right-width : 1px; border-bottom-width : 1px; border-left-width : 1px; border-right-color : inherit; border-left-color : inherit; width : 46%; float : right; } c2left { margin : 1em 1em 0 0; padding-left : 1%; padding-right : 1%; border-style : solid; border-top-width : 1px; border-right-width : 1px; border-bottom-width : 1px; border-left-width : 1px; border-right-color : inherit; border-left-color : inherit; width : 46%; float : left; } box { margin : 0 0 0 0; padding-left : 1%; padding-right : 1%; border-style : solid; border-top-width : 1px; border-right-width : 1px; border-bottom-width : 1px; border-left-width : 1px; border-right-color : inherit; border-left-color : inherit; float : left; } </style> Index: presentations/slides/errorhandling/syntactical.xml +++ presentations/slides/errorhandling/syntactical.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Syntactical Errors</title> <blurb> </blurb> <list fontsize="5em"> <bullet>Parse Errors</bullet> </list> <blurb><![CDATA[<br /> <table align='center' border='1' cellspacing='0'> <tr><td bgcolor='#ffbbbb' colspan="3"><b>Parse error</b>: parse error in <b>/home/httpd/html/test/parse.php</b> on line <b>3</b><br /> <tr><th bgcolor='#aaaaaa' colspan='3'>Call Stack</th></tr> <tr><th bgcolor='#cccccc'>#</th><th bgcolor='#cccccc'>Function</th><th bgcolor='#cccccc'>Location</th></tr> </table>]]></blurb> <list fontsize="5em"> <bullet>Never on a production box</bullet> <bullet>%php -l%</bullet> </list> <blurb> </blurb> <example fontsize="1.5em"><![CDATA[[derick@kossu test]$ php -l parse.php Parse error: parse error in parse.php on line 3]]></example> </slide>