Andy-H Posted June 25, 2010 Share Posted June 25, 2010 The title says it all, I've had a little search and came up with nothing for PHP. Also tried this code, but got an error on line 5, which was to be expected tbh. <?php class test { public $foo = function fooOff($var) { echo "Foo " . $var; } } $test = new test; $test->$foo('Off'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/205820-does-php-have-anonymous-member-functions/ Share on other sites More sharing options...
Andy-H Posted June 25, 2010 Author Share Posted June 25, 2010 Ahh well, apparently not... lol Quote Link to comment https://forums.phpfreaks.com/topic/205820-does-php-have-anonymous-member-functions/#findComment-1077018 Share on other sites More sharing options...
Alex Posted June 25, 2010 Share Posted June 25, 2010 You mean like this? class Foo { public $bar; public function __construct() { $this->bar = function($var) { echo $var; }; } } Quote Link to comment https://forums.phpfreaks.com/topic/205820-does-php-have-anonymous-member-functions/#findComment-1077040 Share on other sites More sharing options...
Andy-H Posted June 29, 2010 Author Share Posted June 29, 2010 Ahh, thanks Quote Link to comment https://forums.phpfreaks.com/topic/205820-does-php-have-anonymous-member-functions/#findComment-1078847 Share on other sites More sharing options...
Mchl Posted June 29, 2010 Share Posted June 29, 2010 That's available since PHP 5.3 Quote Link to comment https://forums.phpfreaks.com/topic/205820-does-php-have-anonymous-member-functions/#findComment-1078849 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.