开发者

preg_match to allow all symbols from keyboards

开发者 https://www.devze.com 2023-03-10 11:58 出处:网络
In codeigniter, they have this function function _clean_input_keys($str) { if ( ! preg_match(\"/^[a-z0-9:_\\/-]+$/i\", $str))

In codeigniter, they have this function

    function _clean_input_keys($str)
{
    if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
    {
        exit('Disallowed Key Characters.');
    }

    return $str;
}

preg_match rul开发者_开发知识库es only accepts alpha numeric text and few other items. But I want to accept all the characters from keyboards such as !@#%^&*()-+?/":[]|~` . How can i change the above preg_match rules to accept all these. Please kindly help me with it. Thank you


Look into the PHP Filter functions. Specifically http://www.php.net/manual/en/filter.filters.sanitize.php FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH

0

精彩评论

暂无评论...
验证码 换一张
取 消