PHP Syntax

PHP script start with the <?php tag and ends with ?> tag. Between the two tags, a PHP script is written. <?php the opening tag and the ?> closing tag tells the engine to treat the enclosed code block as PHP code, rather than simple HTML.

<?php
 // opening tag

echo "Hello, world!";
 // executable block

?> // closing tag
Read also: How to install xampp in windows 10

Embedding PHP within HTML

.php extension is used as the file name suffix.  Inside a PHP file you can write regular HTML code. But ensure that all php codes are enclosed between <?php and ?> tags.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>A Simple PHP File</title>
</head>
<body>
    <h1><?php echo "Hello, world!"; ?></h1>
</body>
</html>

Hope you understand the above code.

PHP Comments

PHP support single-line and also multi-line comments. To write a single-line comment either start the line with either two slashes // or a hash symbol #. For example:

<?php

// This is a single line comment
# This is also a single line comment

echo "Hello, world!";

?>

To write multi-line comments, start the comment with a slash followed by an asterisk /* and end the comment with an asterisk followed by a slash */, like this:

<?php
/*
This is a multiple line comment section
that spans across more than
one line
*/
echo "Hello, world!";
?>

Case Sensitivity in PHP

PHP is case sensitive language means $number and $NUMBER are treated as two different variables.

<?php

$number = 10; //assign 10 to the $number variable

// Print The Value
echo $number; //OUTPUT: 10
echo $NUMBER; //OUTPUT: Undefined Varibale warning for $NUMBER

?>

Hope you got it!