<?php
class Text {
protected $text;
public function __construct(string $text) {
$this->text = $text;
}
public function __toString(): string {
return $this->text;
}
public function get(): string {
return $this->text;
}
}
class Say {
public function greet(string $name) {
echo "Hello {$name}!";
}
}
$bob = new Text('Bob');
$say = new Say();
$say->greet($bob);
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Hello Bob!
Output for 5.6.0 - 5.6.40
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/XK0rb on line 10
Process exited with code 255.