views:

53

answers:

1

Im sure I have seen an implementation of this in PHP somewhere and I am positive if it exists its a PHP 5 thing. Any way I was wondering if it was possible to set and run a function from a string and set the returned value to the value of the string. e.g.

<?php $hi = function(){ return "Hello World"; }; 
echo $hi(); ?>

It probably is not possible but please post anything similar.

Cheers! Franky.

+3  A: 

Anonymous functions were introduced in PHP 5.3.
http://php.net/manual/en/functions.anonymous.php

This is the most recent version, which you may not have installed yet.

deceze