setFirstName click_ur"/>
PHP头条
热点:

PHP中正则表达式转化小写上划线变量变驼峰式


PHP 中 正则表达式转化小写下划线变量变驼峰式
$method = 'set'.preg_replace(
      "/(?:^|_)([a-z])/e",
             "strtoupper('\\1')",
             $f);


如 first_name -> setFirstName
   click_url -> setClickUrl

正则中的/e可以执行. 此特性在perl中也是存在的.

如果不可以执行那只能
a -> A
b -> B
...
z -> Z
不知道还有没有别的办法.

www.phpzy.comtrue/phprm/34706.htmlTechArticlePHP中正则表达式转化小写上划线变量变驼峰式 PHP 中 正则表达式转化小写下划线变量变驼峰式 $method = 'set'.preg_replace( "/(?:^|_)([a-z])/e", "strtoupper('\\1')", $f); 如 first_name -> setFirstName click_ur...

相关文章

PHP之友评论

今天推荐