PHP runs on the server. Code goes between <?php and ?>, and every variable name starts with $.
<?php
$name = "Dara";
$age = 20;
echo "Name: " . $name . ", age: " . $age;Joining strings
PHP joins strings with a dot . rather than +. Inside double quotes you can also write variables directly: "Hello $name".
Code examples
<?php
$city = "Phnom Penh";
echo "Welcome to $city!";Expected output
Welcome to Phnom Penh!
Common mistakes
Common mistake: Forgetting the semicolon
Each PHP statement ends with ;. A missing one causes a "syntax error, unexpected" message.