用来检测指定参数是否合法的PHP变量名。变量名中不能出现汉字等双字节字符。
/**
* 是否合法变量名
* 规定合法变量名为:字母或下划线开头,后跟字母、数字、下划线、短杠。
* 不能使用汉字等双字节字符。
*
* @param string $var
* @return boolean
*/
function is_var($var) {
return !!preg_match('/^[a-z_][a-z0-9-_]*$/i', $var);
}
本文链接http://www.cxybl.com/html/wlbc/Php/20130607/38421.html
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