“comentario de PHP” Código de respuesta

comentario de PHP

1. /* Comment */
2. //Comment
3. #comment
Shadow

PHP Comentarios de la función adecuada

/**
 * This function compiles a message that tells you how great coffee is
 *
 * @param string  $compliment A nice word to describe coffee 
 * @param integer $score      A score out of 10
 */
SmokeFrog

Formas de escribir comentarios en PHP

/*There are two types of comments:
1) Spans over multiple lines - Multiple-line comment
2) Spans over one line only - Sinlge-line comment
*/

/* There are two ways to write a single-line comment:
1) Using double slash
2) Using the hash tag
*/

// This is an example of single-line comment using double slash
# This is an example of single-line comment using hash tag

/*There is only one way of using multiple line comments, startin with the 
slash and asterisk respectively, and ending with asterisk and slash 
respectively */ 
Rick Astley

Comentario en PHP


it's perhaps not obvious to some, but the following code will cause a parse error! the ?> in //?> is not treated as commented text, this is a result of having to handle code on one line such as <?php echo 'something'; //comment ?>

<?php
if(1==1)
{
    //?>
}
?>

i discovered this "anomally" when i commented out a line of code containing a regex which itself contained ?>, with the // style comment.
e.g. //preg_match('/^(?>c|b)at$/', 'cat', $matches);
will cause an error while commented! using /**/ style comments provides a solution. i don't know about # style comments, i don't ever personally use them.
Dev

Comentario en PHP


Comments in PHP can be used for several purposes, a very interesting one being that you can generate API documentation directly from them by using PHPDocumentor (http://www.phpdoc.org/).

Therefor one has to use a JavaDoc-like comment syntax (conforms to the DocBook DTD), example:
<?php
/**
* The second * here opens the DocBook commentblock, which could later on<br>
* in your development cycle save you a lot of time by preventing you having to rewrite<br>
* major documentation parts to generate some usable form of documentation.
*/
?>
Some basic html-like formatting is supported with this (ie <br> tags) to create something of a layout.
Dev

comentario de PHP

// one line comment
hcp top

Respuestas similares a “comentario de PHP”

Preguntas similares a “comentario de PHP”

Más respuestas relacionadas con “comentario de PHP” en PHP

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código