Jump to content


Photo

Comments in PHP


  • Please log in to reply
8 replies to this topic

#1 Re-JeeP

Re-JeeP
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 30 September 2006 - 03:21 PM

Hi!

Where can I learn to use theese kind of comments in php?

/**
*
*
*
**/

// Johan

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 30 September 2006 - 03:28 PM

What do you want to learn about them?
Legend has it that reading the manual never killed anyone.
My site

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 30 September 2006 - 03:31 PM

You can learn about comments over at php.net

#4 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 30 September 2006 - 03:33 PM

Where can I learn to use theese kind of comments in php?


looks like you already know how to use them. basically, andything between your opening '/*' and closing '*/' will be a comment, and the second type is simply a single-line comment. anything following the '//' on that line will be commented out.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#5 GuitarGod

GuitarGod
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 30 September 2006 - 03:34 PM

There isn't much to learn about them.

/***
* I CAN MAKE A
* FEW COMMENTS
* HERE
***/

/*
I CAN ALSO MAKE
COMMENTS LIKE
THIS */

As long as all your comments are between the /* and */, you can pretty much do whatever you want ;)



#6 Re-JeeP

Re-JeeP
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 30 September 2006 - 07:25 PM

Hmm...

I tought that when you for example made an API you used comments like that to describe the class.

For example in java...
http://java.sun.com/...1.5.0/docs/api/

#7 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 30 September 2006 - 07:30 PM

Here's what you need to learn about comments.

One comment in PHP // are mainly use for describing something brief about something in your code.

//loop variable to display names

//This variable will increment by 3 each every Wednesday

and so on...

Multi-line comment can be used for fancy stuff needing a lot explanation in your source code.

/***************
* Title: My code
* Author: me!
* Date: Today
* Program: PHP prog.
* Descripton: Blah blah blah...
**************/

/*
Function: Blah
@params:
$one - it does this
$two - it does that

Blah blah...
*/

Avoid using comments which state the obvious.

//this is a for-loop

#8 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 30 September 2006 - 08:26 PM

Other than holding to the right syntax for comments in php, how many, what style, and how extensive they are is entirely a matter of choice - yours.

Two suggestions:

#1 - adopt a consistent style for comments of various types

#2 - always assume that your code isn't intuitively obvious to the next person who reads it (and that might be you six months later).  Provide comments that help explain the code.
Legend has it that reading the manual never killed anyone.
My site

#9 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 01 October 2006 - 05:13 AM

I tought that when you for example made an API you used comments like that to describe the class.


phpdoc is what your looking for.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users