Home  >  Article  >  php教程  >  字符串命名风格转换

字符串命名风格转换

WBOY
WBOYOriginal
2016-06-07 11:45:551660browse

支持Java风格和C风格的字符串相互转换,ThinkPHP框架内置了该方法。/**<br>  * 字符串命名风格转换<br>  * type 0 将Java风格转换为C的风格 1 将C风格转换为Java的风格<br>  * @param string $name 字符串<br>  * @param integer $type 转换类型<br>  * @return string<br>  */<br> function parse_name($name, $type=0) {<br>     if ($type) {<br>         return ucfirst(preg_replace("/_([a-zA-Z])/e", "strtoupper('\\1')", $name));<br>     } else {<br>         return strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $name), "_"));<br>     }<br> }

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn