Tuesday, January 15, 2019

php - Initialize class property with an anonymous function

Closures do not exist in PHP until PHP 5.3 (the latest version). Make sure you have PHP 5.3 if you want to do this.



In earlier versions, you can sort of duplicate this functionality with the create_function() function, somewhat like this:



$someFunc = create_function($args,$code);
$someFunc();


Where $args is a string formatted like "$x,$y,$z" and $code is a string of your PHP code.

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...