PHP script can be embedded anywhere in the document. The PHP scripts are enclosed within <?
Each statements ends with a semicolon (;).
<title>My PHP Example</title>
<?php echo "Welcome to my first PHP page";?>
The above code when executed will produce the following output.
Welcome to my first PHP page
In PHP, comments are used by a programmer to:
- Hide a block of code.
- Describe your code.
- Write something for others to understand.
All comments will be skipped without executing them. PHP supports single-line and multi-line comments.
A single line comment can be specified in two ways
- Using a # symbol at the beginning of a line.
- Using // at the beginning of a line.
// This is an example of
# a single-line comment
//echo "This line will not be executed";
This code will not produce any output because all the lines (PHP scripts) are commented.
In PHP, you can comment multiple lines by placing the content within /* and */.
/* This is an example
of multi-line comment in PHP*/
echo "This line will /*not*/ be executed";
The above program when executed will produce the following output.
This line will be executed