Basic PHP Syntax
A PHP content can be put anyplace in the report.
A PHP script starts with <?php and ends with ?>:
Syntax -
<?php
// PHP code goes here
?>
The default file extension for "PHP files" is ".php"
Example -
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello World!";
?>
</body>
</html>
// PHP code goes here
?>
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello World!";
?>
</body>
</html>
Comments
<?php
// This is a single-line comment
# This is also a single-line comment
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
// You can also use comments to leave out parts of a code line$x = 5 /* + 15 */ + 5;
echo $x;
?>
// This is a single-line comment
# This is also a single-line comment
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
// You can also use comments to leave out parts of a code line$x = 5 /* + 15 */ + 5;
echo $x;
?>
0 comments:
Post a Comment