PHP Syntax


A PHP script runs on the server and pure HTML results are returned to the browser. PHP scripts can be placed anywhere in the document. PHP statements end with a semicolon (;).

Syntax
<?php
//your code here  
?>
Example
<html>
<body>
<h1>Welcome</h1>
<?php
echo "Hello World!";
?>
</body>
</html>

Output

Welcome
Hello World!

PHP Case Sensitivity

Example
<html>
<body>
<?php
echo "Hi <br>";
ECHO "How are You?<br>";
EcHo "Iam Fine<br>";
?> 
</body>
</html>

Output

Hi
How are You?
Iam Fine

Using HTML, CSS with PHP

Example
<html>
<head>
<title>PHP</title>
</head>
<body>
<?php
$a=10;
$b=20;
$c=$a+$b;
echo "<h1 style='color:red;'>Total : {$c}</h1>"; 
?>
</body>
</html>

Output

Total : 30

Prev Next