Basic PHP Syntax
A PHP script can be placed anywhere in the document.
A PHP script starts with <?php and ends with ?>
<?php
//PHP code goes here
?>
PHP Hello World !!
Code:
<?php
echo "Hello World!!";
?>
Results:
Hello World!!
Note: echo is used to output data to screen.
PHP Case Sensitivity
In PHP, keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-defined functions are not case-sensitive.
Code:
<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?>
Results:
Hello World!
Hello World!
Hello World!
However; all variable names are case-sensitive!
Code:
<?php
$color = "red";
echo "My Pen is ".$color."<br>";
echo "My Pen is ".$Color."<br>";
echo "My Pen is ".$coLor."<br>";
?>
Results:
My Pen is red
My Pen is
My Pen is