{"id":1437,"date":"2018-01-19T19:22:50","date_gmt":"2018-01-19T19:22:50","guid":{"rendered":"http:\/\/goofy-trucks.flywheelsites.com\/file-based-custom-logging-page-3\/"},"modified":"2018-01-19T19:24:47","modified_gmt":"2018-01-19T19:24:47","slug":"file-based-custom-logging-page-3","status":"publish","type":"post","link":"https:\/\/phpbuilder.com\/file-based-custom-logging-page-3\/","title":{"rendered":"File based, custom logging Page 3"},"content":{"rendered":"<div class=\"phpbuilder-content\">\n<div class=\"phpbuilder-meta\">\n<div class=\"\">By John Starkey<\/div>\n<div class=\"\">on September 30, 2002<\/div>\n<\/p><\/div>\n<div id=\"overflow-content\">\n<h2>Breaking the right rules<\/h2>\n<div class=\"articlePara\">\nOk, so we have our function ready to go for handling our logging calls. The next order of business<br \/>\nis to tell the parser that it should use this function for handling any errors. To do this, we will<br \/>\nuse the set_error_handler() function as so:<\/div>\n<div class=\"articlePhpEx\">\n<font face=\"courier\"><code><span style=\"color: #000000\"><\/p>\n<p><span style=\"color: #0000BB\">&lt;?php<br \/>\n<br \/>set_error_handler<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"simplisticLoggingFunction\"<\/span><span style=\"color: #007700\">);<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">?&gt;<br \/>\n<br \/><\/span><br \/>\n<\/span><br \/>\n<\/code><\/font><\/div>\n<div class=\"articlePara\">\nNow, in order to see any results during this demonstration, we&#8217;ll need to create our<br \/>\nown error. To do this, I&#8217;ll use a simple in_array() on a string variable. So, first we<br \/>\ndeclare a variable with a string value:<\/div>\n<div class=\"articlePhpEx\">\n<font face=\"courier\"><code><span style=\"color: #000000\"><\/p>\n<p><span style=\"color: #0000BB\">&lt;?php<br \/>\n<br \/>$fake_array\u00a0<\/span><span style=\"color: #007700\">=\u00a0<\/span><span style=\"color: #DD0000\">'test'<\/span><span style=\"color: #007700\">;<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">?&gt;<br \/>\n<br \/><\/span><br \/>\n<\/span><br \/>\n<\/code><\/font><\/div>\n<div class=\"articlePara\">\nNext, I will create an if statement which will throw an error by testing our faked array<br \/>\nfor the key &#8216;Something&#8217;:<\/div>\n<div class=\"articlePhpEx\">\n<font face=\"courier\"><code><span style=\"color: #000000\"><\/p>\n<p><span style=\"color: #0000BB\">&lt;?php<br \/>\n<br \/><\/span><span style=\"color: #007700\">if\u00a0(\u00a0!<\/span><span style=\"color: #0000BB\">in_array<\/span><span style=\"color: #007700\">(\u00a0<\/span><span style=\"color: #DD0000\">'Something'<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #0000BB\">$fake_array\u00a0<\/span><span style=\"color: #007700\">)\u00a0)\u00a0<br \/>\n<br \/>{<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">trigger_error<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"Humph,\u00a0you\u00a0and\u00a0I\u00a0both\u00a0know\u00a0that\u00a0wasn't\u00a0an\u00a0array\"<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #0000BB\">E_USER_NOTICE<\/span><span style=\"color: #007700\">);\u00a0<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0echo\u00a0<\/span><span style=\"color: #DD0000\">\"An\u00a0error\u00a0has\u00a0been\u00a0posted\u00a0to\u00a0$log_file\"<\/span><span style=\"color: #007700\">;<br \/>\n<br \/>}<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">?&gt;<br \/>\n<br \/><\/span><br \/>\n<\/span><br \/>\n<\/code><\/font><\/div>\n<\/div>\n<p><\/p>\n<div style=\"float: left; padding:15px; color:#17AAF3\">\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"starkey200209304658.html?page=2\">\u00ab Previous Page<\/a><\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"starkey20020930.html\">1<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"starkey200209304658.html?page=2\">2<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"background-color:#B6E5FC; font-size:16px; margin-top:1px; padding:1px 4px 1px 4px; color:#000; font-style:bold; float:left;\">3<\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"starkey20020930fdb0.html?page=4\">4<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"starkey20020930af4d.html?page=5\">5<\/a> <\/div>\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"starkey20020930fdb0.html?page=4\">Next Page \u00bb<\/a><\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In my opinion, the best thing about working in the development phase is the liberty to throw your errors to the browser, without too many worries<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1437","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/comments?post=1437"}],"version-history":[{"count":1,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1437\/revisions"}],"predecessor-version":[{"id":3295,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1437\/revisions\/3295"}],"wp:attachment":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/media?parent=1437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/categories?post=1437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/tags?post=1437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}