Created
June 13, 2013 19:55
-
-
Save adililhan/5776811 to your computer and use it in GitHub Desktop.
PHP'de sınıf içinde bulunan closure fonksiyondan üye metota erişirken PHP 5.3'te Fatal Error veren kod.
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 ClosureTest { | |
| public $getInfo; | |
| public function __construct() { | |
| $this->getInfo = function() { | |
| $this->getCity(); // Bu satir PHP 5.3'te Fatal Error verecektir. | |
| return 'Ben şehir bilgisini getiren metottan sonra çağırıldım.'; | |
| }; | |
| } | |
| public function getCity() { | |
| echo 'Angara'; | |
| } | |
| } | |
| $ClosureTest = new ClosureTest; | |
| // Sinif icindeki closure fonksiyona erismek icin once bir degiskene atama yapmalisiniz. | |
| $ct = $ClosureTest->getInfo; | |
| echo $ct(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment