PHP Syntax and Mixing with HTML
Learn basic PHP syntax and how to embed PHP inside HTML pages.
Daniel Brooks
October 15, 2025
5.1k250
PHP code lives inside special tags in an HTML file.
PHP tags
<?php
// PHP code here
?>
Anything outside is plain HTML.
Example: PHP inside HTML
<!DOCTYPE html>
<html>
<body>
<h1>Welcome</h1>
<p>
<?php
echo "Today is " . date("Y-m-d");
?>
</p>
</body>
</html>
Rules to remember
- Statements end with semicolon ;
- Variables start with $
- PHP is case-sensitive for variables
Comment styles
// single line
# single line
/* multi
line */
Next: Variables, data types, and strings in PHP.
#PHP#Syntax#Beginner