PHP Standard Syntax
A PHP code block must be written inside the PHP opening and closing
tags (<?php …. ?>) called Canonical PHP tags. The start tag tells the PHP parser to begin parsing, and the closing tag tells to end the parsing. The PHP can be embedded within the HTML code, and anything outside the PHP opening and closing tags will be treated as HTML code. The PHP code can be embedded with HTML code, and the file must be saved with a PHP extension.
The PHP code is run on the server-side, and the output that is displayed on the browser is the HTML outcome. When we write the PHP code in a file, we have to save the file on which we have written PHP code with the .php extension.
Before writing the code in PHP, we need to understand a few things:-
1) How a PHP script starts:- PHP script always starts with .
2) How to add comments in PHP code:- You can add comments in a PHP script in two ways-
- By using #
- By using //
We have learned how to write comments ( single-line comments). Let us now see how we can write multiple-line comments or say multiline comments.
PHP case sensitivity:-
1) PHP is not case-sensitive to keywords:- In PHP, we have keywords like echo, if, else, while, etc., and some functions and user-defined functions that are not case-sensitive.
"; EcHo "There are 8 planets in our solar system that we know."; ?>
Both echo and EcHo displayed the output because keywords are non-case sensitive in PHP.
2) PHP is case-sensitive to variable names:- In PHP, when we name variables, we have to remember that variable names are case-sensitive in PHP. Let us understand this with the help of an example:-
"; echo "My Favourite movie is " . $MOVIE . "
"; echo "My Favourite movie is " . $movie . "
In the above example, we can see that only the variable $Movie gives us our output and not the others($MOVIE, $movie). This example shows us that variable names are case-sensitive in PHP.