Home > Programming, php > php: Whats your commenting style?

php: Whats your commenting style?

I was writing up a few scripts and as I was adding my commenting I noticed I tend to comment differently depending on the difficulty of the script and how many different parts or procedures there are to it. I don’t have a set convention, but I suppose as with all things it would make things easier on myself and others if I had some kind of standardization…

For larger ‘areas’ that contain functions or a series of procedures that extract or parse sections of data I’m now starting with this:

/***
*
* This is a comment.
* Here I leave notes about the section and what it does.
* I may also include notes to myself here.
* Note: This could probably be done more eficiently
*
*/

As there are more breakdowns within these sections I’m using this:

/*  [ Parse out the text file ]  */

And further drilled down I use the more inline commenting

/*  [ Print data]  */

$parts = explode("|", $the_array); // get the parts

$color = false; // set color var for shading every other row

print("<table>"); 

// loop through data & print
foreach($parts as $key => $row){ 

    // CSS Note: shading <tr>'s with css mostly works with nice browsers
    // For IE 6+ one needs to shade the <td>'s

    if($color){
        print("<tr class=\"rowColor1\"> "); // start row with color 1
        $color = !$color; // unset the color so it alternates next loop
    } else {
        print("</tr><tr class=\"rowColor2\"> "); // start row with color 2
        $color = true; // set the color so it alternates next loop
    }

    print("<td>$row[first_name]</td></tr>"); // print cell data and close the row
}

print("</td></tr></table>");

The inline comments still seem a bit ‘messy’ to me. But for now it will work.

One of the reasons I decided to standardize is because even with commenting and extra line spaces in the scripts it was still difficult to sort out what exactly was going on. Another thing that tripped my thought was having a glance at phpDocumentor. It seems to function on how you comment your code. I did try to install it but for some reason it was way over my head. It looks like a neat tool but I rarely seem to write more than 4 different files and those are often less than 300-400 lines.

I’ve yet to test it in comments but my plugin to allow code viewing is much like bbc code. [code lang="php"] // comment [/code]

So whats your style? Is there a standard? What have you seen that looks the cleanest? Leave a comment… with some comments ;-)

Update 12/3/07 Elizabeth Naramore has written a nice article on the effectiveness of comments in your code over at the Chris Shiflett blog. It’s a great read on WHY commenting is good in your code.

php, comment, code, script, php+script, php+comment

Categories: Programming, php Tags:
  1. August 14th, 2007 at 08:28 | #1
    /*
    * this does work in the comments too ;-)
    * A nice plugin. Too bad the page it's at is now defunked.
    * Note: The 'Code Snippet' plugin used to be found at blog.enargi.com/codesnippet/
    */
    
  2. March 14th, 2011 at 04:38 | #2

    I was very pleased to find this site. This is an intelligent and well written article, you must have put a fair amount of research into writing this.
    red prom dresses,a line wedding gown

  3. May 17th, 2011 at 03:29 | #3

    ry pleased to find this site. This is an intelligent and well written article, you must have put a fair amount

  4. May 30th, 2011 at 06:38 | #4

    Very nice and impressive article you have posted.

  5. June 9th, 2011 at 02:02 | #5

    Good and nice, I like !

  6. June 27th, 2011 at 23:17 | #6

    Great page you have in here. thanks for sharing.

  7. July 12th, 2011 at 04:22 | #7

    This is a nice article..,

    Its simply super explanation and good examples..

    Thanks a lot:):):)

  8. July 17th, 2011 at 23:18 | #8

    Thanks for your sharing!
    http://www.likehats.com

  9. July 19th, 2011 at 23:33 | #9

    This article was written well ,I like…I will keep your new articles

  10. July 22nd, 2011 at 22:13 | #10

    Beauty is everywhere, but needs eyes to share. I am the eyes to find you! Have a nice day!

  11. July 24th, 2011 at 21:04 | #11

    http://www.setweddingdress.com/accessories.html bridal accessories bridal accessories
    http://www.setweddingdress.com/bridal-party-flower-girls.html girls dresses wedding girls dresses wedding
    http://www.setweddingdress.com/bridal-gowns.html prom gowns prom gowns

  12. August 1st, 2011 at 00:35 | #12

    I think this a good blog post,thanks for sharing.

  13. August 2nd, 2011 at 03:08 | #13

    Thanks for sharing excellent post.Your web

    -site is so cool.I am impressed by the

    details that you’ve on this web site.It

    reveals how nicely you perceive this

    subject.Bookmarked this website page.

  14. August 17th, 2011 at 01:57 | #14

    Thank you for sharing great information to us.I really like this website , and hope you will write more.

  15. August 19th, 2011 at 21:18 | #15

    The article is worth reading,it makes me feel good,http://www.nike-discounts.com/ thanks for the bolg owner.I will keep visiting your blog.

  16. August 23rd, 2011 at 22:51 | #16

    It`s very difficult to meet a man who can be strong and mild, witty and gentle at the same time-and such man-miracle can really turn me on…))

  17. September 8th, 2011 at 06:37 | #17

    The manchester united shirt Premium forms the top this specific kit. Large, design, badge and also the sponsorship logos on the football t shirts allow it to become the real face on the contemporary football.Every club possesses his own football shoes that reflects its aspirations. To point out their support and adoration for their unique team the fans sport the replicas of football shirts 11 12 worm by club team.

  18. September 8th, 2011 at 21:28 | #18

    Although Ugg Boots Clearance primitively known for their diploma the boots, UGG Australia also makes other types of footgear now like carpet slippers, shoes, and sabots. These types of footwear are perfect to be Uggs For Cheap worn just about anyplace and at any time. They can be worn to the office, to school, to the disco, and even to the slopes or the shores. Now, you UGGs Outlet Sale have to think back that if you want to feel and go through the full benefits of parchment on your feet, then you should wear your UGG Delaine Boots Australia footwear, whether boots or shoes, without socks. Because fleece provides great air circulation, you are found that it will keep diaphoresis away from your skin. As UGG Australia the boots are made from this crucial, you can UGG Ultra Tall Boots be distinct that they will be odor free and will stay so for a worse length of time, even in between long periods of Cleanup.

  19. Canny
    September 9th, 2011 at 00:44 | #19

    Most people who have curly hair find it really difficult to black hair style, care for and wear their red hair in a presentable manner. It is true that there are quite a lot of problems associated with curly hair, but with a few simple curly hair care tips.

  20. September 15th, 2011 at 02:42 | #20

    Facebook Ruft Kudos für Gebührenpflichtig Bug Bounties dell vostro 1320 Akku
    Facebook Umzug letzte Woche auf Google, Mozilla und Hewlett-Packard in Kopfgelder für Bugs folgen bekam einen einstimmigen Daumen hoch von Sicherheitsexperten. dell vostro 1000 Akku
    Eine bekannte Schwachstelle Forscher, der ein “No More Free Bugs”-Konzept gedr?ngt hat applaudiert Facebook Entscheidung. dell studio 17 akku

  21. GladisMilhorn
    September 20th, 2011 at 21:07 | #21

    I guess this all depends on who you ask. Some people may say one tattoo machines is too many while others may say four, eight or ten. The point of the matter is you are the only one who can really decide how many tattoo kits wholesale is too many. Of course the size and location of the wholesale tattoo machines also plays a huge part in this decision. For instance, a very attractive looking girl could have a fairly large best tattoo ink on her upper arm, that is a little gaudy and distasteful so some would say that one is too many.

  22. September 23rd, 2011 at 03:55 | #22

    Thanks for share great information to us!

  23. September 25th, 2011 at 20:44 | #23

    Let’s confront it; nothing defines a team a lot more than its uniform. Not only conduct custom wayne rooney jersey make a team look good additionally,it provides it by Authentic drogba jersey dentity while instilling pride and in some instances encouragement for game enthusiasts to kick them Cheap kaka jersey up a notch on the pitch.

  24. September 27th, 2011 at 00:09 | #24

    So informative and helpful code.
    Plumber Bedfordshire

  25. smalldest
    September 27th, 2011 at 00:57 | #25

    If you are still confused about which style would suite you the best then feather hair extensions are a few tips for you that might help you. First, you need to understand yourself. If you have thin hairline then make sure you don’t put-on an expensive feather feather extensions accessory as it would never suite you. Secondly, you can always be a bit innovative and go a step ahead and try some thing different. You can put pins behind your ears and put feathers on it. So there are a lot of alternative ways how you can decorate you cheap feather hair extensions.

  26. September 28th, 2011 at 07:20 | #26

    Thanks for share great information to us!http://www.beatsbydrdree.com

  27. September 28th, 2011 at 12:14 | #27

    want to appreciate the attempts you have made in writing this write-up. I am hoping the same best work of your stuff later on too. In reality your creative writing ability has encouraged me to begin with my personal weblog now.

  28. September 29th, 2011 at 02:40 | #28

    et plus particulièrement le jeu Halo 3.Un spot

  29. September 29th, 2011 at 21:27 | #29

    Harrison was the Uggs Outlet clockmaker whose life’s work was the development of Ugg Boots Knightsbridge on sale first physical marine chronometer. These winders are available as unique, and they would be watching her night and day for Cheap Uggs of unorthodoxy! ed hardy leisure shoes is Uggs Outlet Stores important component of manner?

  30. September 29th, 2011 at 21:28 | #30

    he gathered from some shouted remarks that a convoy of Eurasian prisoners was cheap uggs for sale why not sustain a single to allow yourself an cheap ugg offer more beautiful; hues hygienic and more, He could not now remember whether it was before or after having the uggs outlet that he had seen O’Brien for the first time!

  31. October 4th, 2011 at 01:54 | #31

    We all live in the past. We take a minute to know someone, one hour to like someone, and one day to love someone, but the whole life to forget someone.

  32. October 4th, 2011 at 20:27 | #32

    Unlike other cartoon felines, Felix began his career as a belstaff salemovie star, rather than a cartoon strip. Created by Australian Pat Sullivan, Felix was the star of the first “talkie” cartoon, a
    year before Mickey Mouse began to talk. Felix belstaff ukwas also the subject of the very first television test broadcasts in 1928, and was NBC’s official test pattern until the late 1930’s.

  33. October 4th, 2011 at 22:53 | #33

    This article, write very real, dharma masters have to for this article’s creator our heartfelt admire, this article should look to spread to network let more people visit

  34. October 4th, 2011 at 22:53 | #34

    The only saw wisdom, so good article need good talent to complete, this shows the moderator is definitely a very wise man so good article is really rare, hoped later can often see

  35. October 4th, 2011 at 22:53 | #35

    Thanks for sharing, your this article writes quite, god is like a cup of fragrance of wine, after carefully taste sweet delicious or still so taste is, something good to great sharing

  36. October 4th, 2011 at 22:54 | #36

    Thanks for sharing excellent post.Your web-site is so cool.I am impressed by the details that you’ve on this web site.It reveals how nicely you perceive this subject.Bookmarked this website page.

  37. October 7th, 2011 at 14:38 | #37

    Choosing a down jacket can be a challenge, especially in the cold of winter when time is not of the essence. The choice doesn’t have to be that hard though canada goose jackets for you. Removable coyote fur ruff surrounding a 2-way adjustable tunnel hood with an adjustable bracing wire reduces wind penetration by allowing you to adjust size as conditions dictate. Today straight down canada goose jackets sale can in all likelihood always be one with regard to one of the most beneficial offer you along with regarding grown-up women and men throughout the world. http://www.sale-canadagoosejackets.com
    Proverb said that love me, love my dog. If you like the prairie and like the large group of cute sheep, I bet you will love the Ugg boots,For a more sophisticated look try one of Scarlett Johansson’s favourite hair styles. First straighten your hair with GHD IV Mini Styler and finish with a smoothing cream. Next part your hair right above the arch of one of your eye brows and sweep back into a low side pony tail, right at the nape of your neck, about two inches away from the ear,Ugg classic boots on the same side you created your part http://www.uggclassicboots-sale.com.

  38. October 9th, 2011 at 13:58 | #38

    accounted for a growing proportion thinking that they will Moncler Outlet only need a pure good clothes,moncler is no brand name to Moncler Karak Down Jacket in Purple jack00801 demonstrate my identity.Down Jackets Customers pay the cost to the tailor Moncler Johanna Double breasted Quilted Down Jacket and some commission.Down Jackets Because eliminating the middle part of Moncler Himalaya Down Jacket in Dark Green the sale,moncler is and will not have stock,moncler is

  39. October 9th, 2011 at 14:16 | #39

    staying with you.’ To comfort me?’ Yes, sir, to comfort you, as North Face Sale well as I could.’ And if they laid you under a ban for adhering to North Face Women GoreTex Jacket jack00800 me?’I, probably, North face should know nothing about their ban; North Face Men’s Realization and if I did, I should care nothing about it.’ Then, you could dare North Face Women’s Soft Shell censure for my sake?’ I could dare it for the sake of any friend who

  40. October 10th, 2011 at 07:30 | #40

    is not only faced with tariff adjustments is a luxury,moncler Moncler Outlet is but should be broader in the high-end consumer goods.Down Jackets Moncler maillol Women coffee Coats jack00801 Recently,moncler is the Ministry of Commerce on various Moncler Menuire Down Jacket in Black occasions in the high-end consumer goods,moncler is tariff Moncler Classic Maya Down Jacket in Blue reductions on the support.Down Jackets In recent years,moncler is with the

  41. October 12th, 2011 at 01:32 | #41

    prom dresses 2012 This royal blue dress features a deep sweetheart neckline with center prom dress shops bust and hem embellishment.blue gown The mid section is gathered for a blue dress flattering fit on most body shapes. little black dress Pair with metallic accessories for a pretty ensemble.

  42. October 12th, 2011 at 07:23 | #42

    Canada
    Canada Goose TRILLIUM PARKA white goose down canada goose jackets jacket winter chilly more and extra crucial clothes enterprises, specially who dwell in really cold climate. Everybody loves the heat down materials, but we are generally the finest way to clear and get care of down clothes down. Could undermine the fluffy Canada Goose Sale down jacket on the washing, which is the basis of your warmth is not canada goose parka the correct way, and make it possible for it to form with a tiny dirty alongside the decline. To clear up down right here, aged garments on show, you basically produce it at house some of the critical standards.Canada Goose parkas are born out of purpose and perform. Taking this practicality, we’ve designed a model that embodies our intense weather roots, but incorporates modern day detailing, a slimmer glimpse, and a substantial-shine end. The Kensington Parka will get
    Canada Goose SOLARIS PARKA brown you by a treacherous winter day whilst at same time, incorporating a trendy glimpse.Offers a abundant and distinctive fashion entrance pocket, andover the previous several years is turning into a solution connected with Canada geese. “Firm. Sufficient to dare the Arctic temperature ranges hard, the challenge of Canada goose skin analysis expedition in the Antarctic polar cap water ice have been the operate linked with the scientists for the duration of the previous 20 many years, the finest selection. Inside drawstring waist 550 in the built-in http://www.canadagooseparks.com pure powder skirt shut sizzling and stuffed with power. Usually, when we’re with them, strangers walk up to join us. Our Canada Goose sound their warning honks and typically dive into the pond in their effort to get away from the strangers. They don’t arrive again up to us until the stranger has departed. Often we meet close friends at the park who come to a decision to accompany us although we feed the goose. If our goose are in the pond, they swim towards us but end at the
    Canada Goose WOMEN’S EXPEDITION PARKA black shore, throwing unsure glances towards our friends. It is only when our pals depart that they will come up to us.Canada geese and international brand strategy and wholesale boreal canada goose parka Europe type concise pure design and style perfect blend. Attracted throughout the world trendy pursuit of people’s vision. Is a assortment of European trendy component, leading the globe men’s brand fashionable. Canada goose model design and style strategy, spend consideration to worldwide metropolis plot pursuit. All-around Paris, London, milan, Copenhagen designers receive Europe canada goose on-line sale common element every season and remitted Canada goose model design and style, which includes working people emphasize is modern fashion unique feeling.

  43. October 12th, 2011 at 21:16 | #43

    This was a useful post and I think it is rather easy to see from the other comments as well that this post is well written and useful.

    http://www.topnfljerseyss.us/nfl-jerseys-c-1.html

  44. October 16th, 2011 at 04:16 | #44

    I have great interest in it.

  45. October 18th, 2011 at 19:35 | #45

    Thanks on your marvelous posting! I quite enjoyed reading it.

  46. October 20th, 2011 at 01:32 | #46
  47. October 20th, 2011 at 02:19 | #47

    Thanks for providing this type of very helpful information.

    Your article was great, evident by his comments. I am also happy to read

    I hope you have a nice day! Very good article, well written and very thought out.

  48. Jeannette Pociask
    October 20th, 2011 at 04:20 | #48

    The club’s new discount football jerseys is mainly red featuring a lighter shade of red on both sides of the football shirts spain with the center part being slightly darker. The uruguay football shirts is complemented with red shorts and socks.

  49. October 20th, 2011 at 22:45 | #49

    For over 50 years, Canada Goose Arctic Tech Shearling Pilot Hat has been committed to producing the best expedition parkas, arctic gear, extreme cold weather down jackets and
    http://www.canada-goose-ca.org Canada Goose Jacket high quality outerwear in the world.

  50. October 22nd, 2011 at 01:59 | #50

    Match of North Face Men’s Windstopper different materials mixed with great layering top! It can rain often, particularly in the month of April in some areas. A winter jacket just wont do for this type of weather. You The North Face Denali Fleece Jacket Blue will need a jacket with a lighter material that is water resistant. If you are one of those men, who love to wear jackets in winter or even in other seasons, a href”northfacediscounts”North The North Face Nuptse Goose Down Jacket Face Men’s Denali Jacketsa , then you should get your hands on north face jacket. Many people think that north face outlet Jackets hd been taken as logo at that time, actually The north face denali Gore Tex Jacket Gray t i not. Compared with the traditional insulation materials, new sherry warmth is 1.5 times of feathers, water quantity just 1% of its weight, even in damp environment can The North Face Apex Bionic Jacket Gray still warm

Comment pages
1 2 3 144
  1. October 10th, 2009 at 03:41 | #1