PHP 5 Syntax
A PHP script is executed on the server, and It work server side.
Basic PHP Syntax
A PHP script Can place anywhere in HTML .
A PHP script starts with <?php and ends with ?>:
// PHP code goes here
The PHP file extension is ".php".
A PHP file contains HTML tags and some PHP scripting code.
Below, we have an example of a simple PHP file, with a PHP script that uses a built-in PHP function "echo" to output the text "Hello PHP!" on a web page:
<h1>This is First PHP Program</h1>
echo "Hello PHP!";
Note: PHP statements end with a semicolon (;).
Comments in PHP
A comment in PHP code is a line that is not read/executed as part of the program. Its only for developer reader and stripped out before displaying the programs result.
Comments can be used to:
- It tall programmer what are doing in programme
- single line comment : generally used for short explanations or notes relevant to the local code.
PHP supports several ways of commenting:
// This is a single-line comment
# This is also a single-line comment
This is a multiple-lines comment block
that spans over multiple
// You can also use comments to leave out parts of a code line
$x = 6 /* + 12 */ + 2;
PHP Case Sensitivity
PHP is a case sensitive language :
ECHO "Hello PHP!<br>";
echo "Hello PHP!<br>";
EcHo "Hello PHP!<br>";