Getting started with PHP

Run PHP locally, and use variables and strings.

PHP runs on the server and sends HTML to the browser. Install it directly or through XAMPP, then run php -S localhost:8000 in your project folder.

PHP
<?php
$name = "Kavin";
$age = 20;
echo "Hello $name, you are $age\n";
echo strtoupper($name) . " has " . strlen($name) . " letters\n";
  • Variables start with $.
  • Statements end with a semicolon.
  • The dot joins strings.
  • Double quotes fill in variables; single quotes do not.
Conditions, loops and functions โ†’