PHP Syntax
PHP script on the server is performed and the HTML output is sent to the browser.
A PHP script can be added to any part of the document.
PHP script begins with the character <? PHP and concludes with the character ?>:
".php" is the standard file extension for PHP files.
Normal HTML elements for PHP and some scripting code are included within a PHP file.
Example :-
Here's an example of a simple PHP file, complete with a PHP script that utilises the built-in PHP function "echo"
to produce the word "Hello World!" on a web page:
Output :-
Note:- PHP statements end with a semicolon (;).
Related Links
PHP Case Sensitivity
Classes, functions, and keywords are specified by the user are not cases-sensitive in PHP
(e.g. if
, else
, while
, echo
, and etc).
Example 1 :- In the example below, all three echo statements below are equal and legal:-
";
echo "Hello World!
";
EcHo "Hello World!
";
?>
Output :-
Hello World!
Hello World!
Note :- All variable names, however, must be written in lower case!
Example 2:- Look at the example below; only the first statement will display the value of the $age variable! This is because $age, $AGE, and $aGE are treated as three different variables:-
";
echo "My age is " . $AGE . "
";
echo "My age is " . $aGE . "
";
?>
Output :-
My age is
My age is
Related Links