{"id":568,"date":"2010-03-18T17:29:12","date_gmt":"2010-03-18T23:29:12","guid":{"rendered":"http:\/\/www.evolutionarydesigns.net\/blog\/2010\/03\/18\/how-to-comment-out-php-code\/"},"modified":"2010-03-19T21:49:05","modified_gmt":"2010-03-20T03:49:05","slug":"how-to-comment-out-php-code","status":"publish","type":"post","link":"http:\/\/www.evolutionarydesigns.net\/blog\/2010\/03\/18\/how-to-comment-out-php-code\/","title":{"rendered":"How to Comment Out PHP Code"},"content":{"rendered":"<p>At one time or another, every blogger using <a href=\"http:\/\/www.wordpress.org\" target=\"_blank\">WordPress<\/a> will come across an issue with a plugin or theme that is causing errors. If a bloggers wants to fix these types of issues they need to learn <a href=\"http:\/\/en.wikipedia.org\/wiki\/PHP\" target=\"_blank\">PHP<\/a> to make any <a class=\"zem_slink\" title=\"Database\" rel=\"wikipedia\" href=\"http:\/\/en.wikipedia.org\/wiki\/Database\">database<\/a> coded changes to the system.\u00a0 Lately, I have been going through my <a href=\"http:\/\/www.evolutionarydesigns.net\/blog\/2010\/02\/05\/25-wordpress-plugins-recommend-plugins\/\" target=\"_blank\">plugins<\/a>, and fixing poorly coded plugins and adding new features through pieces of code that I found or had someone create for me. Just playing with the code has taught me a couple of things and one of those that I need to go back relearn PHP the other is that <a class=\"zem_slink\" title=\"Comment out\" rel=\"wikipedia\" href=\"http:\/\/en.wikipedia.org\/wiki\/Comment_out\">commenting out<\/a> PHP code can be helpful if you temporarily want to block code from running during testing.<\/p>\n<h2>Types of PHP Comments<\/h2>\n<p>There are two types of comments you can use with PHP. Those are,\u00a0 single comment, and mult-iline commenting<\/p>\n<h3>Single Line Comments:<\/h3>\n<p>Single line comments tells the interpreter to block everything that is on same line to the right of the comment. You can use &#8220;\/\/&#8221; or &#8220;#&#8221;\u00a0 and everything after after the comment will be ignored.<\/p>\n<h3>Code example:<\/h3>\n<blockquote style=\"width: 699px; height: 124px;\"><p>&lt;?php<br \/>\necho &#8220;Hello World!&#8221;; \/\/ This will print out Hello World!<br \/>\necho &#8220;&lt;br \/&gt;Can you see the comments?\u201d; \/\/ echo &#8220;I bet you can&#8221;;<br \/>\n\/\/ echo &#8220;Hello world.!&#8221;;<br \/>\n# echo &#8220;you can use the hash tag to remove lines of code as well&#8221;;<br \/>\n# echo \u201care you sure you can see me?\u201d<br \/>\n?&gt;<\/p><\/blockquote>\n<h4>Printed Code:<\/h4>\n<blockquote><p>Hello World!<br \/>\nCan you see the comments?<\/p><\/blockquote>\n<h3>Multiple Line Comment<\/h3>\n<p>Muli-line PHP comments are used to write multiple line comments. It can also be used comment out large blocks of code.\u00a0 Use the multi-line comment and place \u201c\/* at the beginning of code you want to block off. Then place \u201c*\/\u201d at the end of code needing to be blocked off. This is what it should look like.<\/p>\n<h4>Code Example:<\/h4>\n<blockquote style=\"width: 722px; height: 129px;\"><p>&lt;?php<br \/>\n\/* Message goes here. *\/<br \/>\necho &#8220;Hello World!&#8221;;<br \/>\n\/* echo &#8220;Can see me?&#8221;; echo &#8220;No?&#8221;; *\/<br \/>\n?&gt;<\/p><\/blockquote>\n<p>Printed Code:<\/p>\n<blockquote><p>Hello World!<\/p><\/blockquote>\n<h2>Recommendations: When to Use Comments<\/h2>\n<p>All though my experience with PHP is very limited, I recommend that you always use comments when you can. But don\u2019t go overboard. Use it when you add extra code or if there is a very complicated piece of code you are working. Its always good to have a comment or two about what\u00a0 you are trying to do or what its suppose to do. This can not only be helpful to you in the future if you need to make changes, but if you ever have to hand your site over to a PHP developer to work on your site, he or she has an idea what you did.<\/p>\n<p><input id=\"gwProxy\" type=\"hidden\" \/><\/p>\n<p><!--Session data--><br \/>\n<input id=\"jsProxy\" onclick=\"jsCall();\" type=\"hidden\" \/><\/p>\n<div class=\"zemanta-pixie\" style=\"margin-top: 10px; height: 15px;\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"zemanta-pixie-img\" style=\"border: medium none; float: right;\" src=\"https:\/\/i0.wp.com\/img.zemanta.com\/pixy.gif\" alt=\"\" \/><span class=\"zem-script pretty-attribution\"><script src=\"http:\/\/static.zemanta.com\/readside\/loader.js\" type=\"text\/javascript\"><\/script><\/span><\/div>\n<p><input id=\"gwProxy\" type=\"hidden\" \/><input id=\"jsProxy\" onclick=\"jsCall();\" type=\"hidden\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>At one time or another, every blogger using WordPress will come across an issue with a plugin or theme that is causing errors. If a bloggers wants to fix these types of issues they need to learn PHP to make any database coded changes to the system.\u00a0 Lately, I have been going through my plugins, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[14],"tags":[158,132,325,326,1481],"class_list":["post-568","post","type-post","status-publish","format-standard","hentry","category-tutorials","tag-howto","tag-php","tag-php-comment-code","tag-php-comment-code-examples","tag-wordpress","entry"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pJPdG-9a","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/www.evolutionarydesigns.net\/blog\/wp-json\/wp\/v2\/posts\/568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.evolutionarydesigns.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.evolutionarydesigns.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.evolutionarydesigns.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.evolutionarydesigns.net\/blog\/wp-json\/wp\/v2\/comments?post=568"}],"version-history":[{"count":0,"href":"http:\/\/www.evolutionarydesigns.net\/blog\/wp-json\/wp\/v2\/posts\/568\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.evolutionarydesigns.net\/blog\/wp-json\/wp\/v2\/media?parent=568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.evolutionarydesigns.net\/blog\/wp-json\/wp\/v2\/categories?post=568"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.evolutionarydesigns.net\/blog\/wp-json\/wp\/v2\/tags?post=568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}