This article mainly introduces the PHP from the string creation function method, involves in the PHP string and the Create_function function use skill, needs the friend to be possible to refer to under
This example describes how PHP creates a function from a string. Share to everyone for your reference. Specifically as follows:
PHP can put the entire function definition in a string dynamic definition, with the Create_function function, you can dynamically create a function based on user input, very convenient, create_function use the method as shown in the example:
The code is as follows: <?php
$lambda =create_function (' $a, $b ', ' Return (strlen ($a)-strlen ($b));
$array = Array (' Really long string here,boy ', ' this ', ' middling length ', ' larger ');
Usort ($array, $LAMBDA);
Print_r ($array);
?>
I hope this article will help you with your PHP program design.