PHP Syntax Basics in PHP
From the PHP cheat sheet · Setup & Basics · verified Jul 2026
PHP Syntax Basics
Basic PHP syntax and structure
php
<?php
// Single line comment
/* Multi-line
comment */
// Variables (dynamic typing)
$name = "PHP";
$version = 8.3;
$isAwesome = true;
// Constants
const APP_NAME = "MyApp";
define('VERSION', '1.0.0');
// Output
echo "Hello $name";
print("Hello");
var_dump($variable);
// Include files
require 'config.php';
include 'header.php';💡 PHP files start with <?php tag
📌 Variables always start with $ sign
⚡ Use require for critical files, include for optional
🔥 Constants are globally accessible and immutable