Last active
September 21, 2019 22:55
-
-
Save Chemaclass/382488091b3bde21b8a79f87ec26877a to your computer and use it in GitHub Desktop.
Docu - Closure::call
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 | |
| class A { | |
| private $x = "1"; | |
| } | |
| // Pre PHP 7 code | |
| $getX = function() {return $this->x;}; | |
| $getXCB = $getX->bindTo(new A, 'A'); // intermediate closure | |
| echo $getXCB(); // outputs "1" | |
| // PHP 7+ code | |
| $getX = function() {return $this->x;}; | |
| echo $getX->call(new A); // outputs "1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment