PHP/Language Basics/Comments

Материал из Web эксперт
Версия от 07:05, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

A comment is text in a script that is ignored by the PHP engine.

 
Single-line comments begin with two forward slashes (//) or a single hash sign (#). 
<?
// this is a comment
# this is another comment
?>



Combine three types of comment signs

<?
// This is a simple PHP comment.
/* This is a C-style, multiline comment. You can make this as
long as you"d like. */
# Used to shells? Use this kind of comment.
?>



In PHP, everything between /* and */ is considered a comment

 
// or # may be used to "comment out" the remainder of a single line:
<?php
    $var = "foo";        // This is all ignored
    $var = "bar";        # so is this
?>



Multiline comments

 
<?
/* line1
   - A
   - B
   - C
*/
print "line 5";
print "Cost: 3.25 + 9.50 + 25.00";
?>



Multiline comments begin with a forward slash followed by an asterisk (/*) and end with an asterisk followed by a forward slash (*/)

 
<?
/*
this is a comment
none of this will
be parsed by the
PHP engine
*/
?>



PHP comments are usually preceded by double slashes

<?
// this is a comment in PHP code
echo "This is not a comment."
?>



Php more than single line comment

/* This begins a C-style comment that runs
onto two lines */



Php single line comment:#

# This is shell-style style comment



PHP supports C, C++ and Unix shell-style comments

 
<?php
    echo "This is a test"; // This is a one-line c++ style comment
    /* This is a multi line comment
    yet another line of comment */
    echo "This is yet another test";
    echo "One Final Test"; # This is shell-style style comment
?>



shell style comments

 
<?php
     # Title: My PHP program
     # Author: Tom
     print "This is a PHP program";
?>