Skip to content

Instantly share code, notes, and snippets.

@adililhan
Created June 13, 2013 19:55
Show Gist options
  • Select an option

  • Save adililhan/5776811 to your computer and use it in GitHub Desktop.

Select an option

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.
<?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