Home > Backend Development > PHP Tutorial > PHP URL参数检测问题

PHP URL参数检测问题

WBOY
Release: 2016-06-06 20:21:03
Original
1174 people have browsed it

函数如下:

<code>function check_name($action) {
    if(strpos($action, '__') !== false || strpos($action, '--') !== false)
        return false; 
        
    return preg_match("/^[a-z0-9]{1}[a-z0-9_\-]{0,}[a-z0-9]{1}$/", $action);
}
</code>
Copy after login
Copy after login

$action是URL参数,这样做有什么意义呢?

回复内容:

函数如下:

<code>function check_name($action) {
    if(strpos($action, '__') !== false || strpos($action, '--') !== false)
        return false; 
        
    return preg_match("/^[a-z0-9]{1}[a-z0-9_\-]{0,}[a-z0-9]{1}$/", $action);
}
</code>
Copy after login
Copy after login

$action是URL参数,这样做有什么意义呢?

个人觉得可能是—__这种的多为私有方法,这样访问可能确保不会访问到私有的action吧

不就是验证一个字符串是不是符合规则么 完了呢?

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template