comments in php

Solutions on MaxInterview for comments in php by the best coders in the world

showing results for - "comments in php"
Juan David
10 Aug 2016
1/**
2 * This function compiles a message that tells you how great coffee is
3 *
4 * @param string  $compliment A nice word to describe coffee 
5 * @param integer $score      A score out of 10
6 */
Ella
06 May 2016
1
2A nice way to toggle the commenting of blocks of code can be done by mixing the two comment styles:
3<?php
4//*
5if ($foo) {
6  echo $bar;
7}
8// */
9sort($morecode);
10?>
11
12Now by taking out one / on the first line..
13
14<?php
15/*
16if ($foo) {
17  echo $bar;
18}
19// */
20sort($morecode);
21?>
22..the block is suddenly commented out.
23This works because a /* .. */ overrides //. You can even "flip" two blocks, like this:
24<?php
25//*
26if ($foo) {
27  echo $bar;
28}
29/*/
30if ($bar) {
31  echo $foo;
32}
33// */
34?>
35vs
36<?php
37/*
38if ($foo) {
39  echo $bar;
40}
41/*/
42if ($bar) {
43  echo $foo;
44}
45// */
46?>
47
48
Madeleine
17 Jul 2017
1
2Comments do NOT take up processing power.
3
4So, for all the people who argue that comments are undesired because they take up processing power now have no reason to comment ;)
5
6<?php
7
8// Control
9echo microtime(), "<br />"; // 0.25163600 1292450508
10echo microtime(), "<br />"; // 0.25186000 1292450508
11
12// Test
13echo microtime(), "<br />"; // 0.25189700 1292450508
14# TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST
15# .. Above comment repeated 18809 times ..
16echo microtime(), "<br />"; // 0.25192100 1292450508
17
18?>
19
20They take up about the same amount of time (about meaning on a repeated testing, sometimes the difference between the control and the test was negative and sometimes positive).
21
Kiara
29 Nov 2018
1
2MSpreij (8-May-2005) says  /* .. */ overrides //  
3Anonymous (26-Jan-2006) says // overrides /* .. */
4
5Actually, both are correct. Once a comment is opened, *everything* is ignored until the end of the comment (or the end of the php block) is reached.
6
7Thus, if a comment is opened with: 
8   //  then /* and */ are "overridden" until after end-of-line 
9   /*  then // is "overridden" until after */
10
Maissa
12 Jan 2020
1
2<h1>This is an <?php # echo 'simple';?> example</h1>
3<p>The header above will say 'This is an  example'.</p>
4
Giulia
29 Jun 2019
1
2Be careful when commenting out regular expressions.
3
4E.g. the following causes a parser error.
5
6I do prefer using # as regexp delimiter anyway so it won't hurt me ;-)
7
8<?php 
9
10/*
11
12 $f->setPattern('/^\d.*/');
13
14*/
15
16?>
17
18
queries leading to this page
comment out php code in htmlhow to comment on phpcommenter phpmethod comment in phpcreate comments in php to methodhow to make a comment in phpcomment on phpcomment phpcomments script in phpphp function arguments commenthow to commend in phpnew line on php comment documentationphp function commentphp 09 line commentphp function description commentphpcs function commentphp code documentationhow to do comments in phpcomment clause to include along with in php codephp how to write helpful commentsblock comments phpdifferent types of comments in phpphp function documentation formatphp function funcionality documentation examplelaravel comments above functionsphp combig comment in php codephp script how to comment inlinewriting comments above methods laravelphp param commentdoc comments phpphp comment function standardphp adding commentswell written php classphp doc commentphp documentation commentsphp comment sectionphp comentcomment v phpcomments php template examplewhat comment style to use with phpphp how to write meaningful commentscomment all code in phpdefine 28 29 php doc commentcomment blocks of code in phphow to comment php codephp function comment blocknotes in phpwhat are php doc commentsphp comments 40php function explanation commentcomments for phptool design php commentscomment single line in phpcomment block phpcomments phpcode to create a comment section in phpfunction comment phpmethod comment block phpblock comments in php with 40paramphp function help blockcomments on what the function does phpdisplay on comment the value in phpget method info comment block phpproperly comment php codecomments method phphow to make my line of code in php commentadd comment on phpbeautiful comments phpadd a comment in phpphp function cariable in commectsphp class comments standardsphp function comment 40paramphp writing documentationphp comphp comment documentationphp code showing ways of commenting in phpphp function documentation examplemethod commenting phpphp function definition commentphp documentation commentingphp comments examplephp documentation comments exceptionhow to echo comment field in phpparam comment phphow to add comments in numbers in phpcomments phpphp commentingphpdoc commentsphp proper function commentshow to create comments phpadd comment to parameter phpphp code commentercomment php codecomment out js in php filehow to make comment in phphow to comment in phpphp version doc commentsphp comments oopcomments on phpcomment code in phpcomment system phpphp comment blockhow to make php commentsinline comment in phphow to add comments in posts in phpphp tags turn into commentsall comments in phphow to comment out php codephp comment syntaxphp function comment stylefunction comment pattern phpcomment on a php functionpost comments phpphp function header commentspeoper commenting in phpphp function descriptionhow to comment phphow should we add a single line comment in our php code 3fcomments for documentation in phpphp comments 40returnsphp commentscomment out line phpphp comment documentation examplecomment documentation phpsingle line comment in phpcomment section phpphp function documentationphp block commentsparameter comment phpadd comment with phpphp function description comment vscomment function phpphp comhow to comment out php in htmlhowto comment out phpset php tags in commentphp simple function comment example how to give comment in phphow to write comment in php functioncomment php and html codecommenting in phphow to comment php tagscomments in phpphp function comment examplephp how to add comments n your webdisqus comments phpphp ini commentsphp commentidentify the comment clause to include along with in php codecommenting format for phpcomment php sectioncooment phpphp commentwsadd comments plugin for phpphp allows which commenting formatphp comment descriptionphp format commentscommenting out phpget comments phpcomment php htmlphp commentaarphp code comments documentationphp comment 40commentare phpphp comment outphp doc commentscomment in php 23 php commentmethod commenting php for functionsphp commentarephp method commentshow to add comments in phpphp function help block paramgenerate method comments in phpphp comments syntax parametershow to get comment in phpcomments of 2f 2fphpcscomment end phpcomment with phpphp comment for functionphp comment systemphp write function commentscomments text show in phphow to comment in php filephp comment htmlways of commenting in phpcomment for function in php for documentationall php doc commentphp docs commentscomment code in php 3c php comment methodhow to write comment in phphow to leave comments in phpcant comment in phpcommenting in php languagephp comment function php function comentshow to comment php code in htmlcomentar phphow do you create a comment on php scriptphp function commentsphp comments pluginphp best way to comment funnctionphp comments systmecomments in php my sqlcomment in php block codephp summary commentsoftware that documents php code from commentscomment out phpcomments in php