Jump to content

Comments in PHP


Re-JeeP

Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.