How to Comment Out PHP Code

Disclosure: We are a professional review site that receives compensation from the companies whose products we review. We test each product thoroughly and give high marks to only the very best. We are independently owned and the opinions expressed here are our own.

0 Flares Filament.io 0 Flares ×

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.  Lately, I have been going through my plugins, 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 commenting out PHP code can be helpful if you temporarily want to block code from running during testing.

Types of PHP Comments

There are two types of comments you can use with PHP. Those are,  single comment, and mult-iline commenting

Single Line Comments:

Single line comments tells the interpreter to block everything that is on same line to the right of the comment. You can use “//” or “#”  and everything after after the comment will be ignored.

Code example:

<?php
echo “Hello World!”; // This will print out Hello World!
echo “<br />Can you see the comments?”; // echo “I bet you can”;
// echo “Hello world.!”;
# echo “you can use the hash tag to remove lines of code as well”;
# echo “are you sure you can see me?”
?>

Printed Code:

Hello World!
Can you see the comments?

Multiple Line Comment

Muli-line PHP comments are used to write multiple line comments. It can also be used comment out large blocks of code.  Use the multi-line comment and place “/* at the beginning of code you want to block off. Then place “*/” at the end of code needing to be blocked off. This is what it should look like.

Code Example:

<?php
/* Message goes here. */
echo “Hello World!”;
/* echo “Can see me?”; echo “No?”; */
?>

Printed Code:

Hello World!

Recommendations: When to Use Comments

All though my experience with PHP is very limited, I recommend that you always use comments when you can. But don’t 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  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.


EvolutionaryDesigns.net runs on the Genesis Framework

Genesis Framework

Genesis empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go. It's that simple - start using Genesis now!


Take advantage of the 6 default layout options, comprehensive SEO settings, rock-solid security, flexible theme options, cool custom widgets, custom design hooks, and a huge selection of child themes ("skins") that make your site look the way you want it to. With automatic theme updates and world-class support included, Genesis is the smart choice for your WordPress website or blog.

About James

James spends most of his free time using social media and loves to teach others about design, web development, CSS, SEO, and social media. He is addicted to Wordpress, social media, and technology. You can reach him on his, personal website, Do not forget to follow him on Twitter @element321

Comments

  1. [url=http://my.curse.com/members/Kally1.aspx]KENDRA WILKINSON UNCENSORED[/url]
    [url=http://my.curse.com/members/Kally1.aspx]KENDRA WILKINSON UNCENSORED[/url]
    [url=http://my.curse.com/members/Olly13.aspx]KIM KARDASHIAN BLOWJOB[/url]
    [url=http://my.curse.com/members/Olly13.aspx]KIM KARDASHIAN BLOWJOB[/url]
    [url=http://my.curse.com/members/SandlerOk1984.aspx]LINDSAY LOHAN FAKES[/url]
    [url=http://my.curse.com/members/SandlerOk1984.aspx]LINDSAY LOHAN FAKES[/url]
    [url=http://my.curse.com/members/Roling1989.aspx]MEGAN FOX CAMEL TOE[/url]
    [url=http://my.curse.com/members/Roling1989.aspx]MEGAN FOX CAMEL TOE[/url]
    [url=http://my.curse.com/members/alexxx1982.aspx]MEGAN FOX DESNUDA[/url]
    [url=http://my.curse.com/members/alexxx1982.aspx]MEGAN FOX DESNUDA[/url]

Trackbacks

  1. RT @element321: How to Comment Out PHP Code http://bit.ly/aPKyIk

  2. Voooz says:

    RT @FamousBloggers: RT @element321: How to Comment Out PHP Code http://bit.ly/aPKyIk

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Flares Twitter 0 Facebook 0 Pin It Share 0 Buffer 0 Email -- Filament.io 0 Flares ×
%d bloggers like this: