- // single-line comments can be like this
- # or even like this
- /* multi-line comments can be like this */
- ; The semicolon at the end of the statement is important!
- the PHP command echo is a means of outputting text to the web browser
Comparison chart
| echo can take more than one parameter when used without parentheses. The syntax is echo expression [, expression[, expression] ... ]. Note that echo ($arg1,$arg2) is invalid. | print only takes one parameter. |
| echo does not return any value | print always returns 1 (integer) |
| void echo ( string $arg1 [, string $... ] ) | int print ( string $arg ) |
| In PHP, echo is not a function but a language construct. | In PHP, print is not a really function but a language construct. However, it behaves like a function in that it returns a value. |
The print() function is slightly slower than echo().
<html>
<head>
<title>Hello World! PHP</title>
</head>
<body>
<h1>Examples</h1>
<?php echo "Hello World!"; ?>
<br />
<?php
// print works like echo
print "Hello World!";
?>
<br />
<?php
// concatenation
echo "Hello" . " World!<br />";
// simple math
echo 2 + 3;
?>
<br />
</body>
</html>
No comments:
Post a Comment