Jump to content

Archived

This topic is now archived and is closed to further replies.

Re-JeeP

Comments in PHP

Recommended Posts

You can learn about comments over at [url=http://www.php.net/manual/en/language.basic-syntax.comments.php]php.net[/url]

Share this post


Link to post
Share on other sites
[quote author=Re-JeeP link=topic=110079.msg444250#msg444250 date=1159629666]
Where can I learn to use theese kind of comments in php?
[/quote]

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.

Share this post


Link to post
Share on other sites
There isn't much to learn about them.

[code]/***
* I CAN MAKE A
* FEW COMMENTS
* HERE
***/[/code]

[code]/*
I CAN ALSO MAKE
COMMENTS LIKE
THIS */[/code]

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

Share this post


Link to post
Share on other sites
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/j2se/1.5.0/docs/api/

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote]I tought that when you for example made an API you used comments like that to describe the class.[/quote]

[url=http://phpdoc.org]phpdoc[/url] is what your looking for.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.