Asking for what isn't there
A Config with one public property, one private array, and the __get and __call magic methods.
<?phpclass Config { private array $data = ['host' => 'db']; public string $mode = 'live'; public function __get(string $name): string { echo "__get($name)\n"; return $this->data[$name] ?? 'none'; } public function __call(string $name, array $args): string { return "$name called with " . count($args); }}$c = new Config();echo $c->mode, "\n";echo $c->host, "\n";echo $c->port, "\n";echo $c->reload(1, 2), "\n";1. Predict the output
Tap the lines in the order you think they print.
- 1…
- 2…
- 3…
- 4…
- 5…
- 6…