Last active
July 19, 2018 19:02
-
-
Save Majkl578/d6054802b8286ee271c3a4ec182fca87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$hello = 'Hello'; | |
$world = 'World'; | |
$speaker = new class use ($hello as public, $world as private $who) { | |
public function say() : void | |
{ | |
echo $this->hello . ' ' $this->who, PHP_EOL; | |
} | |
}; | |
$speaker->say(); // Hello World | |
$speaker->hello = 'Hola'; | |
$speaker->say(); // Hola World | |
$speaker->who = 'Mundo'; // visibility error | |
$speaker->say(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment