Skip to content

Instantly share code, notes, and snippets.

@yamashiro
Created December 3, 2012 05:30
Show Gist options
  • Save yamashiro/4192961 to your computer and use it in GitHub Desktop.
Save yamashiro/4192961 to your computer and use it in GitHub Desktop.
PHPでクラスのフィールドに関数オブジェクトを入れる
<?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