PHP/Language Basics/Comments
Содержание
- 1 A comment is text in a script that is ignored by the PHP engine.
- 2 Combine three types of comment signs
- 3 In PHP, everything between /* and */ is considered a comment
- 4 Multiline comments
- 5 Multiline comments begin with a forward slash followed by an asterisk (/*) and end with an asterisk followed by a forward slash (*/)
- 6 PHP comments are usually preceded by double slashes
- 7 Php more than single line comment
- 8 Php single line comment:#
- 9 PHP supports C, C++ and Unix shell-style comments
- 10 shell style comments
A comment is text in a script that is ignored by the PHP engine.
<source lang="html4strict">
Single-line comments begin with two forward slashes (//) or a single hash sign (#). <? // this is a comment
- this is another comment
?>
</source>
Combine three types of comment signs
<source lang="html4strict">
<? // 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.
?>
</source>
In PHP, everything between /* and */ is considered a comment
<source lang="html4strict">
// 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
?>
</source>
Multiline comments
<source lang="html4strict">
<? /* line1
- A - B - C
- /
print "line 5"; print "Cost: 3.25 + 9.50 + 25.00"; ?>
</source>
Multiline comments begin with a forward slash followed by an asterisk (/*) and end with an asterisk followed by a forward slash (*/)
<source lang="html4strict">
<? /* this is a comment none of this will be parsed by the PHP engine
- /
?>
</source>
PHP comments are usually preceded by double slashes
<source lang="html4strict">
<? // this is a comment in PHP code echo "This is not a comment." ?>
</source>
Php more than single line comment
<source lang="html4strict">
/* This begins a C-style comment that runs onto two lines */
</source>
Php single line comment:#
<source lang="html4strict">
- This is shell-style style comment
</source>
PHP supports C, C++ and Unix shell-style comments
<source lang="html4strict">
<?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
?>
</source>
shell style comments
<source lang="html4strict">
<?php
# Title: My PHP program # Author: Tom print "This is a PHP program";
?>
</source>