{"id":2615,"date":"2019-05-20T10:46:06","date_gmt":"2019-05-20T17:46:06","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=2615"},"modified":"2020-12-29T12:52:42","modified_gmt":"2020-12-29T20:52:42","slug":"how-to-debug-php","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/","title":{"rendered":"How to Debug PHP Without Experience"},"content":{"rendered":"\n<p>Oh, you\u2019ve done it this time. You\u2019ve always been confident about your technical skills and have worked your way up the ladder within your organization to work on their servers. You sit down to work on a reported issue&#8211; and you have to debug PHP code. PHP is a server-side programming language that you can use for a broad range of tasks, but you\u2019ve never worked with it before this shift, and you\u2019re at a loss as to how you should go about debugging PHP. You don\u2019t even know where to begin.<br><\/p>\n\n\n\n<p>Calm down, my sysadmin pal. We\u2019ve developed this guide for such an occasion, so you\u2019ve got nothing to worry about. We walk you through the PHP debugging process, beginning with standard debug actions that you can use when working with most languages and finishing with PHP-specific debugging tools that will let you cut through the red tape and figure out exactly what\u2019s causing your server to act so sad all the time. Soon, you\u2019ll be a PHP-coding wizard!<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Output and Dump<\/strong><\/h2>\n\n\n\n<p>To get started with PHP debug, you\u2019ll want to know exactly what you\u2019re dealing with as far as the world of PHP errors. There are some excellent third-party apps that you can use to debug PHP, such as Xdebug but, since you\u2019re a brand-new server admin, still wet behind the ears and covered with packing foam, we\u2019ll start you with nothing but PHP. That\u2019s fine, though\u2014PHP has lots of fantastic debugging tools to help you along the way.<br><\/p>\n\n\n\n<p>You\u2019ll want to output your values to STDOUT so that you can review it to check for errors. You can dump your output to the log using a couple of different commands; you can use var_dump ($var) to dump a specified variable, and you can use type and print_r ($var) to produce a human-readable variable dump. Use these commands to start building your log.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/6_Kf4SqHoGBkKOgOgCFGMsRP0_1PIlmr2L5CV7oHuO45McnuF6E16eA8ZfQm2BAX6fA67vmS7vhu8eor1CwUFYtD22JNb2-ACq-HoMaKs0E87hYgCJLACe3dO0FV36ugx-Np241N\" alt=\"\u201dShallow focus photography of computer codes\u201d\"\/><figcaption>Before you know it, you\u2019ll be hip deep in bad code. Hooray!<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step Through Your Code<\/strong><\/h2>\n\n\n\n<p>Eventually, just scanning the logs won\u2019t be enough to figure out what\u2019s wrong with your PHP code. Sooner or later, you\u2019re going to need to <em>step through your code<\/em> to find the issue. Stepping through code is standard practice in any programming environment or language. It allows you to watch the program in action and keep track of all of its functions. Stepping through your code is an effective way to pinpoint the exact point at which your program went sideways and started throwing errors.<br><\/p>\n\n\n\n<p>Those PHP debug extensions we touched on earlier will come in handy to help you work your way through the code. Xdebug and other debuggers will allow you to build servers that can mimic your production servers\u2019 environment. A good debug environment will allow you to do anything that you can do on your actual network there so that you can keep your bug squashing risk-free since you won\u2019t have to worry about disrupting your company\u2019s service while you get all Sherlock Holmes on the problem.<br><\/p>\n\n\n\n<p>So, you can relax and breathe easy the next time you have to dig through your server\u2019s PHP code to identify an issue. Use your logs and debuggers, and make sure to step through your program. In no time at all, your PHP code will be pristine and purring like a cute and logical kitten.<\/p>\n","protected":false},"excerpt":{"rendered":"Oh, you\u2019ve done it this time. You\u2019ve always been confident about your technical skills and have worked your way up the ladder within your organization to work on their servers. You sit down to work on a reported issue-- and you have to debug PHP code. PHP is a server-side programming language that you can&hellip;","protected":false},"author":21,"featured_media":2616,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[18069],"tags":[],"class_list":{"0":"post-2615","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-web-development-skills"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Web Development","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Debug PHP Without Experience | Career Karma<\/title>\n<meta name=\"description\" content=\"If you work with servers, you\u2019ll need to debug PHP code. Our guide will show you how and take the mystery out of debugging!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Debug PHP Without Experience\" \/>\n<meta property=\"og:description\" content=\"If you work with servers, you\u2019ll need to debug PHP code. Our guide will show you how and take the mystery out of debugging!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-20T17:46:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-29T20:52:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/05\/kobu-agency-798655-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"805\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Paul Larkin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Larkin\" \/>\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:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/\"},\"author\":{\"name\":\"Paul Larkin\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/1761df0013e0bbfeb16c0d4078e4685d\"},\"headline\":\"How to Debug PHP Without Experience\",\"datePublished\":\"2019-05-20T17:46:06+00:00\",\"dateModified\":\"2020-12-29T20:52:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/\"},\"wordCount\":588,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/kobu-agency-798655-unsplash.jpg\",\"articleSection\":[\"Web Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/\",\"name\":\"How to Debug PHP Without Experience | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/kobu-agency-798655-unsplash.jpg\",\"datePublished\":\"2019-05-20T17:46:06+00:00\",\"dateModified\":\"2020-12-29T20:52:42+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/1761df0013e0bbfeb16c0d4078e4685d\"},\"description\":\"If you work with servers, you\u2019ll need to debug PHP code. Our guide will show you how and take the mystery out of debugging!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/kobu-agency-798655-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/kobu-agency-798655-unsplash.jpg\",\"width\":1200,\"height\":805,\"caption\":\"hello world text\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/how-to-debug-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Development\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/web-development-skills\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Debug PHP Without Experience\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/1761df0013e0bbfeb16c0d4078e4685d\",\"name\":\"Paul Larkin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/paul-larkin-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/paul-larkin-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/paul-larkin-150x150.jpg\",\"caption\":\"Paul Larkin\"},\"description\":\"Paul Larkin has years of experience in the tech industry and writes about cybersecurity and future of work.\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/paul-larkin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Debug PHP Without Experience | Career Karma","description":"If you work with servers, you\u2019ll need to debug PHP code. Our guide will show you how and take the mystery out of debugging!","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:\/\/careerkarma.com\/blog\/how-to-debug-php\/","og_locale":"en_US","og_type":"article","og_title":"How to Debug PHP Without Experience","og_description":"If you work with servers, you\u2019ll need to debug PHP code. Our guide will show you how and take the mystery out of debugging!","og_url":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2019-05-20T17:46:06+00:00","article_modified_time":"2020-12-29T20:52:42+00:00","og_image":[{"width":1200,"height":805,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/05\/kobu-agency-798655-unsplash.jpg","type":"image\/jpeg"}],"author":"Paul Larkin","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"Paul Larkin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/"},"author":{"name":"Paul Larkin","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/1761df0013e0bbfeb16c0d4078e4685d"},"headline":"How to Debug PHP Without Experience","datePublished":"2019-05-20T17:46:06+00:00","dateModified":"2020-12-29T20:52:42+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/"},"wordCount":588,"commentCount":1,"image":{"@id":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/05\/kobu-agency-798655-unsplash.jpg","articleSection":["Web Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/how-to-debug-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/","url":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/","name":"How to Debug PHP Without Experience | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/05\/kobu-agency-798655-unsplash.jpg","datePublished":"2019-05-20T17:46:06+00:00","dateModified":"2020-12-29T20:52:42+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/1761df0013e0bbfeb16c0d4078e4685d"},"description":"If you work with servers, you\u2019ll need to debug PHP code. Our guide will show you how and take the mystery out of debugging!","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/how-to-debug-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/05\/kobu-agency-798655-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2019\/05\/kobu-agency-798655-unsplash.jpg","width":1200,"height":805,"caption":"hello world text"},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/how-to-debug-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Web Development","item":"https:\/\/careerkarma.com\/blog\/web-development-skills\/"},{"@type":"ListItem","position":3,"name":"How to Debug PHP Without Experience"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/1761df0013e0bbfeb16c0d4078e4685d","name":"Paul Larkin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/paul-larkin-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/paul-larkin-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/paul-larkin-150x150.jpg","caption":"Paul Larkin"},"description":"Paul Larkin has years of experience in the tech industry and writes about cybersecurity and future of work.","url":"https:\/\/careerkarma.com\/blog\/author\/paul-larkin\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/2615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=2615"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/2615\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/2616"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=2615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=2615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=2615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}