PHP code must be written inside <?php ... ?> tags:
Everything inside the tags is interpreted by the PHP engine.
Each PHP statement ends with a semicolon:
Variable names are case-sensitive, but keywords like if, echo, and while are not:
$Name = "Alice";
echo $Name; // works
echo $name; // undefinedPHP supports single-line and multi-line comments:
// This is a single-line comment
# This is another single-line comment
/*
This is a
multi-line comment
*/PHP ignores extra whitespace, but consistent indentation improves readability.
<?php
$a = 10;
$b = 20;
if ($a < $b) {
echo "A is less than B";
}
?><html>
<body>
<?php
echo "<h1>Hello from PHP!</h1>";
?>
</body>
</html>You can switch between HTML and PHP seamlessly in one file.
Ask the AI if you need help understanding or want to dive deeper in any topic