PHP/Functions/create function
A Simple Anonymous Function
<html>
<body>
<div>
<?php
$my_anon = create_function( "$a, $b", "return $a+$b;" );
print $my_anon( 3, 9 );
?>
</div>
</body>
</html>
Dynamically Creating Functions
<?php
if (count($_POST) > 0) {
$prepped = create_function("$a", "return trim($_POST[$a]);");
}
elseif (count($_GET) > 0) {
$prepped = create_function("$a", "return strtoupper($_GET[$a]);");
}
else {
$prepped = create_function("$a", "return false;");
}
echo $prepped("file");
?>