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.
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";
?>