Introduction to PHP

PHP is a popular general-purpose scripting language especially suited to web development. It is fast, flexible, and pragmatic, powering everything from blogs to the most popular websites in the world.

Install PHP from php.net or use a package manager:

sudo apt install php
if ($a > $b) {
echo "a is greater than b";
} elseif ($a == $b) {
echo "a is equal to b";
} else {
echo "a is less than b";
}
for ($i = 0; $i < 5; $i++) {
echo $i;
}
while ($a < 10) {
$a++;
}
function greet($name) {
return "Hello, $name!";
}
$arr = array(1, 2, 3);
echo $arr[0];
$name = $_POST['name'];
echo $name;
$file = fopen("test.txt", "r");
while(!feof($file)) {
echo fgets($file);
}
fclose($file);