4. Understanding PHP Syntax and Tags
While PHP is embedded within HTML, it has strict rules regarding its own syntax.
Case Sensitivity
In PHP, variable names are case-sensitive, but built-in functions, keywords (if, echo, while), and class names are case-insensitive.
php
Using caps for echo."; eChO "Using mixed case for echo."; ?>
Statements and Semicolons
Every individual statement in PHP must be terminated with a semicolon (;). Forgetting the semicolon is one of the most common beginner errors.
php
Note: Semicolons are not required after the closing PHP tag (?>) or after the closing brace of a block (}).
Comments
Comments are non-executable parts of the code used for documentation.
-
Single-line comments: php
-
Multi-line comments: php