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'); ?> 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 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; }; } } 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 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 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
Archived
This topic is now archived and is closed to further replies.