PHP Syntax

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
// PHP code goes here
?>

".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:

<!DOCTYPE html>
<html>
<body>
<?php
echo "Hello World!";
?>
</body>
</html>

Output :-

Hello World!

Note:- PHP statements end with a semicolon (;).



You can also search for these topics, php syntax, php syntax list, php syntax overview, php syntax and variables, php syntax check command line, php syntax is most similar to, php syntax example.

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:-

<!DOCTYPE html>
<html>
<body>
<?php
ECHO "Hello World!<br />";
echo "Hello World!<br />";
EcHo "Hello World!<br />";
?>
</body>
</html>

Output :-

Hello World!
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:-

<!DOCTYPE html>
<html>
<body>
<?php
$age = "23";
echo "My age is " . $age . "<br />";
echo "My age is " . $AGE . "<br />";
echo "My age is " . $aGE . "<br />";
?>
</body>
</html>

Output :-

My age is 23
My age is
My age is



You can also search for these topics, check php case-sensitive or not, php case sentitive example, php case sensitive comparision, php case sensitive function, php case sensitivity keyword, php case sensitive variables.