PHP旧版本函数create_function
php吧
全部回复
仅看楼主
level 1
PHP旧版本的create_function在新版本中已经弃用
有没哪位高手可以帮忙修改一下旧脚本
$var = preg_replace_callback('/[_-]+(.)?/i', create_function('$matches', 'return strtoupper($matches[1]);'), $option);
2024年08月15日 07点08分 1
level 9
$var = preg_replace_callback('/[_-]+(.)?/i', function($matches) {
return isset($matches[1]) ? strtoupper($matches[1]) : '';
}, $option);
2024年08月15日 07点08分 2
可以直接写成 fn($matches) => strtoupper($matches[1] ?? '') 代码更简洁
2024年08月15日 08点08分
1