Created
December 3, 2012 05:30
-
-
Save yamashiro/4192961 to your computer and use it in GitHub Desktop.
PHPでクラスのフィールドに関数オブジェクトを入れる
This file contains 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 Hoge { | |
function __construct() { | |
$this->func = function () { | |
print("func"); | |
}; | |
} | |
function init() { | |
$foo = $this->func; | |
$foo(); | |
} | |
} | |
$hoge = new Hoge; | |
$hoge->init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment