AnatomyOf

Anatomy of a PHP file

example.php
1<?php
2
3class Greeter
4{
5 private string $greeting;
6
7 public function __construct(string $greeting)
8 {
9 $this->greeting = $greeting;
10 }
11
12 public function greet(string $name): string
13 {
14 return "$this->greeting, $name!";
15 }
16}
17
18// To iterate is human, to recurse divine
19$greeter = new Greeter("Hello");
20echo $greeter->greet("Alice");
PHP is a widely-used open-source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.