TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Start comments in PHP: /* or /** (http://www.talkphp.com/absolute-beginners/3314-start-comments-php.html)

Dave 09-03-2008 10:07 AM

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

sketchMedia 09-03-2008 10:51 AM

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.

Ross 09-03-2008 12:19 PM

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); 


zspencer 09-04-2008 12:36 PM

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.

Village Idiot 09-04-2008 07:23 PM

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

Jim 09-04-2008 08:14 PM

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 :)

sketchMedia 09-04-2008 08:31 PM

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.

Dave 09-07-2008 12:40 PM

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

Dave

Jim 09-08-2008 07:58 PM

Additional to my first post, it might be intressting to note that you can actually read the /** comments on runtime in PHP yourself :)

boycoda 09-09-2008 08:46 AM

I used # or ## myself. Works just as good.

sketchMedia 09-09-2008 06:39 PM

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

shell Code:
#!/usr/bin/php -q

Ross 09-09-2008 06:59 PM

Quote:

Originally Posted by sketchMedia (Post 18295)
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 :-)

sketchMedia 09-10-2008 10:38 AM

Quote:

Originally Posted by redSHIFT (Post 18297)
I don't use hash because it just looks ugly to me :-)

That too 8-)

Kalle 09-11-2008 07:53 AM

PERL style comments should be terminated, just like asp_tags =P

boycoda 09-11-2008 09:34 AM

asp itself should be terminated. All hail php and that #

caiyanfang 03-30-2013 07:55 AM

Retro can is an work in nike free run shoes genre and music, and also cricket it only translates to the worst numbers through a score-sheet. At the lower part of the Mack Bridge Test, India's digits were dire: 0-2 inside of a four-Test series, is better than by 196 this kind of 319 runs, and get totals of 285, 261, 288 and 158 so far. This was no way the India for their perpetual scrap, advantages bouncebackability quotient, the no. 1 Test review (in that precise order through significance). On what develop into the nike free run 3 final afternoon linked with an Test, as the wickets column on line giant scoreboard eventually left of the pavilion ticked in place ominously, Sachin Tendulkar, emerges for 56, could have been playing in an increased grim 1990s. At one end of the pitch was regular posting intent of top quality. At the all, a revolving door.


All times are GMT. The time now is 09:55 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0