xiaozi 2017-03-08 16:35:29

如何执行字符表达式 `($x + $y) * 2`,相比于 eval, create_function 或许是个更好的选择。

php php
$dynamic_func = create_function('$x, $y', 'return ($x + $y) * 2;');
echo $dynamic_func(1, 2) . PHP_EOL; // 6

评论

- 위키
Copyright © 2011-2025 iteam. Current version is 2.142.0. UTC+08:00, 2025-02-23 01:44
浙ICP备14020137号-1 $방문자$