{"id":106,"date":"2013-11-18T14:16:43","date_gmt":"2013-11-18T14:16:43","guid":{"rendered":"http:\/\/jobshuk.com\/yirmi\/?p=106"},"modified":"2013-11-18T14:16:43","modified_gmt":"2013-11-18T14:16:43","slug":"oy-vey-debugging","status":"publish","type":"post","link":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/","title":{"rendered":"Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger"},"content":{"rendered":"<p dir=\"LTR\">While it is much easier and more efficient to use a debugger such as x-debug to debug your PHP web application, there may be some difficulties on the server stopping one from implementing x-debug.\u00a0 In this case, we are forced to use the classic debug methods instead.\u00a0 This article will elaborate on the implementing classic methods in web programming.<\/p>\n<p dir=\"LTR\"><b>Displaying Debug Messages<\/b><\/p>\n<p dir=\"LTR\">The simplest way to debug is to display debug messages.\u00a0 The standard PHP function to do this is &#8220;<code>var_dump()<\/code>&#8220;.\u00a0 <code>var_dump()<\/code> can be used to display data, including arrays and objects.\u00a0 With large objects or arrays, the data may be truncated, so you may need to specify the element in the array or object or specifically cast it to a string if it is a virtual string.\u00a0 You can also use <code>var_dump()<\/code> or <code>echo<\/code> to confirm that a certain line was indeed executed.<\/p>\n<p dir=\"LTR\">One disadvantage is that having these extra displays, if left in the production code, there could be unprofessional looking displays on the website.\u00a0 To avoid this, one should always check the diff before checking in the code.\u00a0 But then again, if the problem occurs on production, you will never be able to use this method to debug, as it will disrupt the website.\u00a0 To avoid this potential pitfall, there are alternatives.<\/p>\n<p dir=\"LTR\">One alternative debugging method is writing it to a log.\u00a0 This will enable to website to display correctly, while the error may be checked only by those with access to the log.\u00a0 In addition, one can set up their system to write to the log in different events in order to diagnose potential issues and monitor system behavior.\u00a0 Another possibility is to use a tool such as firePHP (a Firefox plugin), in order to have messages only displayed in the firePHP.\u00a0 This may allows the developer to check without having to access a log.\u00a0 Still, since anyone can install firePHP and view your confidential debugging messages, it is best to have it turned off in production.<\/p>\n<p dir=\"LTR\"><b>&#8220;Oy Vey&#8221; Debugging \u2013 Forcing a Crash<\/b><\/p>\n<p dir=\"LTR\">One problem with the previous approach is that the method is prone to failure.\u00a0 The log could fail to be written for a\u00a0 number of reasons.<\/p>\n<p><code>var_dump()<\/code> and echo could be disabled if the system buffers and flushes the output.\u00a0 Using third-party plugins is also not 100% reliable. \u00a0Browsers and plugins are always being updated, and new versions can have compatibility issues.<\/p>\n<p dir=\"LTR\">Another issue is that, while displaying or logging a message will indicate that a line of code was executed, it will might not tell you how you got there.\u00a0 You can still use <code>debug_backtrace()<\/code>, but there is another way.<\/p>\n<p dir=\"LTR\"><code>trigger_error('oy vey');<\/code><\/p>\n<p dir=\"LTR\"><code>throw new Exception('oy vey');<\/code><\/p>\n<p dir=\"LTR\">The error screen now displays all the info you need.<\/p>\n<p dir=\"LTR\">Still, some systems will trap your errors, so in order to force a fatal error by calling a non-existent function.<\/p>\n<p dir=\"LTR\"><code>oyvey();<\/code><\/p>\n<p dir=\"LTR\">Or you can also try<\/p>\n<p dir=\"LTR\"><code>die('oy vey');<\/code><\/p>\n<p dir=\"LTR\">Just make sure to remove all the debugging stuff before checking in your changes.\u00a0 The grand World Wide Web audience wants to see a working website and not &#8220;oy vey&#8221;.<\/p>\n<p dir=\"LTR\"><b>The Blank Screen<\/b><\/p>\n<p dir=\"LTR\">Sometimes, none of this helps.\u00a0 Something is causing the program to crash, and your page turns up blank.\u00a0 How do you find the guilty line of code?\u00a0 Sometimes, with thorough knowledge of you project, you can guess what the problem is.\u00a0 But what when you have no idea why your page is blank?\u00a0 One possibility is to go to the top starting code in your system is see what executes.\u00a0 From there, you can work your way top-down into sub-functions.\u00a0 Another classic debugging method is to comment out everything and uncomment until you find the guilty line.<\/p>\n<p dir=\"LTR\">Using these different methods, you can generally solve your website&#8217;s issues without a debugger.<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"<p>While it is much easier and more efficient to use a debugger such as x-debug to debug your PHP web application, there may be some difficulties on the server stopping one from implementing x-debug.\u00a0 In this case, we are forced to use the classic debug methods instead.\u00a0 This article will elaborate on the implementing classic &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger&#8221;<\/span><\/a><\/p>\n\n\n","protected":false},"author":375,"featured_media":107,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[68,69,67,6,70],"class_list":["post-106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-debugger","tag-debugging","tag-oy-vey","tag-php","tag-web-applications","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger - Yirmi&#039;s World of Web Widgets by Yirmiyahu Fischer<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger - Yirmi&#039;s World of Web Widgets by Yirmiyahu Fischer\" \/>\n<meta property=\"og:description\" content=\"While it is much easier and more efficient to use a debugger such as x-debug to debug your PHP web application, there may be some difficulties on the server stopping one from implementing x-debug.\u00a0 In this case, we are forced to use the classic debug methods instead.\u00a0 This article will elaborate on the implementing classic &hellip; Continue reading &quot;Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/\" \/>\n<meta property=\"og:site_name\" content=\"Yirmi&#039;s World of Web Widgets by Yirmiyahu Fischer\" \/>\n<meta property=\"article:published_time\" content=\"2013-11-18T14:16:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jobshuk.com\/yirmi\/files\/2013\/11\/oyvey.png\" \/>\n\t<meta property=\"og:image:width\" content=\"161\" \/>\n\t<meta property=\"og:image:height\" content=\"121\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"yirmi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"yirmi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/\"},\"author\":{\"name\":\"yirmi\",\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/#\\\/schema\\\/person\\\/3ad2fc75c4041622134d8f0f14a2102e\"},\"headline\":\"Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger\",\"datePublished\":\"2013-11-18T14:16:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/\"},\"wordCount\":620,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/files\\\/2013\\\/11\\\/oyvey.png\",\"keywords\":[\"debugger\",\"debugging\",\"oy vey\",\"PHP\",\"web applications\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/\",\"url\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/\",\"name\":\"Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger - Yirmi&#039;s World of Web Widgets by Yirmiyahu Fischer\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/files\\\/2013\\\/11\\\/oyvey.png\",\"datePublished\":\"2013-11-18T14:16:43+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/#\\\/schema\\\/person\\\/3ad2fc75c4041622134d8f0f14a2102e\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/files\\\/2013\\\/11\\\/oyvey.png\",\"contentUrl\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/files\\\/2013\\\/11\\\/oyvey.png\",\"width\":161,\"height\":121},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/2013\\\/11\\\/18\\\/oy-vey-debugging\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/#website\",\"url\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/\",\"name\":\"Yirmi&#039;s World of Web Widgets by Yirmiyahu Fischer\",\"description\":\"Blog of a PHP Web Programmer\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/#\\\/schema\\\/person\\\/3ad2fc75c4041622134d8f0f14a2102e\",\"name\":\"yirmi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/wp-content\\\/uploads\\\/avatars\\\/375\\\/8c2adaf748317e659d83f249c32af044-bpfull.jpg\",\"url\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/wp-content\\\/uploads\\\/avatars\\\/375\\\/8c2adaf748317e659d83f249c32af044-bpfull.jpg\",\"contentUrl\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/wp-content\\\/uploads\\\/avatars\\\/375\\\/8c2adaf748317e659d83f249c32af044-bpfull.jpg\",\"caption\":\"yirmi\"},\"url\":\"https:\\\/\\\/jobshuk.com\\\/yirmi\\\/author\\\/yirmi\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger - Yirmi&#039;s World of Web Widgets by Yirmiyahu Fischer","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/","og_locale":"en_US","og_type":"article","og_title":"Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger - Yirmi&#039;s World of Web Widgets by Yirmiyahu Fischer","og_description":"While it is much easier and more efficient to use a debugger such as x-debug to debug your PHP web application, there may be some difficulties on the server stopping one from implementing x-debug.\u00a0 In this case, we are forced to use the classic debug methods instead.\u00a0 This article will elaborate on the implementing classic &hellip; Continue reading \"Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger\"","og_url":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/","og_site_name":"Yirmi&#039;s World of Web Widgets by Yirmiyahu Fischer","article_published_time":"2013-11-18T14:16:43+00:00","og_image":[{"width":161,"height":121,"url":"https:\/\/jobshuk.com\/yirmi\/files\/2013\/11\/oyvey.png","type":"image\/png"}],"author":"yirmi","twitter_card":"summary_large_image","twitter_misc":{"Written by":"yirmi","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/#article","isPartOf":{"@id":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/"},"author":{"name":"yirmi","@id":"https:\/\/jobshuk.com\/yirmi\/#\/schema\/person\/3ad2fc75c4041622134d8f0f14a2102e"},"headline":"Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger","datePublished":"2013-11-18T14:16:43+00:00","mainEntityOfPage":{"@id":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/"},"wordCount":620,"commentCount":0,"image":{"@id":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/#primaryimage"},"thumbnailUrl":"https:\/\/jobshuk.com\/yirmi\/files\/2013\/11\/oyvey.png","keywords":["debugger","debugging","oy vey","PHP","web applications"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/","url":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/","name":"Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger - Yirmi&#039;s World of Web Widgets by Yirmiyahu Fischer","isPartOf":{"@id":"https:\/\/jobshuk.com\/yirmi\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/#primaryimage"},"image":{"@id":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/#primaryimage"},"thumbnailUrl":"https:\/\/jobshuk.com\/yirmi\/files\/2013\/11\/oyvey.png","datePublished":"2013-11-18T14:16:43+00:00","author":{"@id":"https:\/\/jobshuk.com\/yirmi\/#\/schema\/person\/3ad2fc75c4041622134d8f0f14a2102e"},"breadcrumb":{"@id":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/#primaryimage","url":"https:\/\/jobshuk.com\/yirmi\/files\/2013\/11\/oyvey.png","contentUrl":"https:\/\/jobshuk.com\/yirmi\/files\/2013\/11\/oyvey.png","width":161,"height":121},{"@type":"BreadcrumbList","@id":"https:\/\/jobshuk.com\/yirmi\/2013\/11\/18\/oy-vey-debugging\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jobshuk.com\/yirmi\/"},{"@type":"ListItem","position":2,"name":"Oy Vey Debugging \u2013 Fixing PHP Web applications without a debugger"}]},{"@type":"WebSite","@id":"https:\/\/jobshuk.com\/yirmi\/#website","url":"https:\/\/jobshuk.com\/yirmi\/","name":"Yirmi&#039;s World of Web Widgets by Yirmiyahu Fischer","description":"Blog of a PHP Web Programmer","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jobshuk.com\/yirmi\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/jobshuk.com\/yirmi\/#\/schema\/person\/3ad2fc75c4041622134d8f0f14a2102e","name":"yirmi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jobshuk.com\/yirmi\/wp-content\/uploads\/avatars\/375\/8c2adaf748317e659d83f249c32af044-bpfull.jpg","url":"https:\/\/jobshuk.com\/yirmi\/wp-content\/uploads\/avatars\/375\/8c2adaf748317e659d83f249c32af044-bpfull.jpg","contentUrl":"https:\/\/jobshuk.com\/yirmi\/wp-content\/uploads\/avatars\/375\/8c2adaf748317e659d83f249c32af044-bpfull.jpg","caption":"yirmi"},"url":"https:\/\/jobshuk.com\/yirmi\/author\/yirmi\/"}]}},"_links":{"self":[{"href":"https:\/\/jobshuk.com\/yirmi\/wp-json\/wp\/v2\/posts\/106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jobshuk.com\/yirmi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jobshuk.com\/yirmi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jobshuk.com\/yirmi\/wp-json\/wp\/v2\/users\/375"}],"replies":[{"embeddable":true,"href":"https:\/\/jobshuk.com\/yirmi\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":0,"href":"https:\/\/jobshuk.com\/yirmi\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jobshuk.com\/yirmi\/wp-json\/wp\/v2\/media\/107"}],"wp:attachment":[{"href":"https:\/\/jobshuk.com\/yirmi\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jobshuk.com\/yirmi\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jobshuk.com\/yirmi\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}