Hi all,
i have taken from net script that it has curriying function which itself return function.
But i dont understand why before \$arg is added backslash. the same as on lines 10, 13, 19 and so on.
function add($a, $b)
{
return $a + $b;
}
$az="";
function _curry( $function, $num_args )
{
return create_function('', "
\$args = func_get_args();
// Execute the function if the right number of arguments were passed
if( count(\$args)>=$num_args )
{
return call_user_func_array('$function', \$args);
}
// Export the function arguments as executable PHP code
\$args = var_export(\$args, 1);
// Return a new function with the arguments stored otherwise
return create_function('','
\$a = func_get_args();
\$z = ' . \$args . ';
\$a = array_merge(\$z,\$a);
return call_user_func_array(\'$function\', \$a);
');
");
}
$func =_curry('add', 2);
Thanks for attention