TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-03-2008, 10:07 AM   #1 (permalink)
The Acquainted
 
Dave's Avatar
 
Join Date: Apr 2008
Posts: 110
Thanks: 97
Dave is on a distinguished road
Default Start comments in PHP: /* or /**

My PHP IDE does not seem to recognize /** as the beginning of PHP comments. It does recognize /* as the beginning, however.

When I see other's code, I often see /** used to begin PHP comments.

Question: Is the /* comment */ method pretty much accepted everywhere?

Thanks,
Dave
Dave is offline  
Reply With Quote
Old 09-03-2008, 10:51 AM   #2 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

I think /** is what PHPDoc looks for before it parses comments.

What is your IDE just out of interest, it sounds like there syntax matching algo is incorrect.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
The Following User Says Thank You to sketchMedia For This Useful Post:
Dave (09-03-2008)
Old 09-03-2008, 12:19 PM   #3 (permalink)
The Contributor
 
Ross's Avatar
 
Join Date: Jan 2008
Location: England, UK
Posts: 83
Thanks: 3
Ross is on a distinguished road
Default

In Java, Javadoc (the equivalent of PHPdoc) uses /** */ comments for Javadoc comments and /* */ for plain comments.

I tend to use a /** */ when doing a multiline comment, a /* */ on an line comment detailing a section of code and a // when detailing the next few lines.

For example:

PHP Code:
/**
 * Page-level docblock
 */

/* Editing the file */

// Open, write and close
$f fopen('file.html''w');
fwrite($f'tets');
fclose($f); 
Ross is offline  
Reply With Quote
The Following User Says Thank You to Ross For This Useful Post:
Dave (09-03-2008)
Old 09-04-2008, 12:36 PM   #4 (permalink)
The Wanderer
 
Join Date: Sep 2008
Posts: 6
Thanks: 1
zspencer is on a distinguished road
Default

That is interesting. I use gedit for Linux and it recognizes anything starting with /* as a comment. Thus /***** counts as a comment, and *****/ counts as a closing comment.
zspencer is offline  
Reply With Quote
The Following User Says Thank You to zspencer For This Useful Post:
Dave (09-07-2008)
Old 09-04-2008, 07:23 PM   #5 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,298
Thanks: 17
Village Idiot is on a distinguished road
Default

What IDE do you use? Because PHP should ignore anything between the "/*" and "*/" tags regardless of what they are.
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
Dave (09-07-2008)
Old 09-04-2008, 08:14 PM   #6 (permalink)
Jim
The Addict
 
Jim's Avatar
 
Join Date: Nov 2007
Location: the Netherlands
Posts: 281
Thanks: 2
Jim is on a distinguished road
Default

Here is an example:

/**
* Applies the main template to the page
*
* @param string $file
* @param bool $first
*/

If the PHP parser spots /** it starts reading the whole comment block for later (possible) usage. So /** is not just for yourself, but it's actually used in parsetime (i will explain later). When using /* it will be just ignored.

The good thing about /** is for combinating /** information with the Reflection API, you can creating your own doc system.

Also very nice is using it in Zend Studio. When you are working on some others code, some sort of API. You can see much information about a function without looking in the code of the API writher, because ZS shows you the information from /** when starting the function.

You have to check it out to be convinced :)
__________________
Nunchaku! Who doesn't like martial arts? =)
Send a message via MSN to Jim Send a message via Skype™ to Jim
Jim is offline  
Reply With Quote
The Following 2 Users Say Thank You to Jim For This Useful Post:
Dave (09-07-2008), Y.P.Y (09-15-2008)
Old 09-04-2008, 08:31 PM   #7 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

This is a PHPDoc block comment, therefore its for the PHPDoc parser not PHP parser itself and as VI correctly said:
Quote:
PHP should ignore anything between the "/*" and "*/" tags regardless of what they are.
Im guessing that Zend Studio (and indeed eclipse) reads PHPDoc comments and uses them to provide more comprehensive code completion hints.

The double '*' is there for the PHPDoc parser, as far as i know.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
The Following 2 Users Say Thank You to sketchMedia For This Useful Post:
Dave (09-07-2008), Y.P.Y (09-15-2008)
Old 09-07-2008, 12:40 PM   #8 (permalink)
The Acquainted
 
Dave's Avatar
 
Join Date: Apr 2008
Posts: 110
Thanks: 97
Dave is on a distinguished road
Default

That is interesting, and clears up the /* vs. /** "issue" up for me very well. Thank you!

Dave
Dave is offline  
Reply With Quote
The Following User Says Thank You to Dave For This Useful Post:
Y.P.Y (09-15-2008)
Old 09-08-2008, 07:58 PM   #9 (permalink)
Jim
The Addict
 
Jim's Avatar
 
Join Date: Nov 2007
Location: the Netherlands
Posts: 281
Thanks: 2
Jim is on a distinguished road
Default

Additional to my first post, it might be intressting to note that you can actually read the /** comments on runtime in PHP yourself :)
__________________
Nunchaku! Who doesn't like martial arts? =)
Send a message via MSN to Jim Send a message via Skype™ to Jim
Jim is offline  
Reply With Quote
Old 09-09-2008, 08:46 AM   #10 (permalink)
The Wanderer
 
Join Date: Feb 2008
Location: United Kingdom
Posts: 22
Thanks: 1
boycoda is on a distinguished road
Default

I used # or ## myself. Works just as good.
Send a message via MSN to boycoda Send a message via Skype™ to boycoda
boycoda is offline  
Reply With Quote
Old 09-09-2008, 06:39 PM   #11 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

I dont use '#' because it looks like the she-bang line when running PHP on the CLI:

shell Code:
#!/usr/bin/php -q
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 09-09-2008, 06:59 PM   #12 (permalink)
The Contributor
 
Ross's Avatar
 
Join Date: Jan 2008
Location: England, UK
Posts: 83
Thanks: 3
Ross is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
I dont use '#' because it looks like the she-bang line when running PHP on the CLI:

shell Code:
#!/usr/bin/php -q
I don't use hash because it just looks ugly to me
Ross is offline  
Reply With Quote
The Following User Says Thank You to Ross For This Useful Post:
Y.P.Y (09-15-2008)
Old 09-10-2008, 10:38 AM   #13 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Quote:
Originally Posted by redSHIFT View Post
I don't use hash because it just looks ugly to me
That too
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 09-11-2008, 07:53 AM   #14 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

PERL style comments should be terminated, just like asp_tags =P
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 09-11-2008, 09:34 AM   #15 (permalink)
The Wanderer
 
Join Date: Feb 2008
Location: United Kingdom
Posts: 22
Thanks: 1
boycoda is on a distinguished road
Default

asp itself should be terminated. All hail php and that #
Send a message via MSN to boycoda Send a message via Skype™ to boycoda
boycoda is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:36 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design