Php 输入验证安全性-不允许使用http://或https://
我试着做一些基本的验证。我想使提交链接不可能。 我写了一些半好的代码。 如果在输入的开始处使用Php 输入验证安全性-不允许使用http://或https://,php,string,validation,Php,String,Validation,我试着做一些基本的验证。我想使提交链接不可能。 我写了一些半好的代码。 如果在输入的开始处使用http://或https://,则该选项不起作用 if(((stripos($message, "http://")) || (stripos($message, "https://"))) !== false) { echo"Link is Here"; } else { echo"Link is NOT Here"; } 有没有办法解决这个问题。我使用函数s
http://
或https://
,则该选项不起作用
if(((stripos($message, "http://")) || (stripos($message, "https://"))) !== false)
{
echo"Link is Here";
}
else
{
echo"Link is NOT Here";
}
有没有办法解决这个问题。我使用函数
stripos
,因为我必须确保http://
和https://
不区分大小写,所以我可以使用所有类型的托盘,例如http://
或https://
这与您的if
语句有关。将其更改为:
if(stripos($message, "http://") !== false || stripos($message, "https://") !== false)
{
echo "Link is here";
}
else
{
echo "Link is NOT here";
}
if(stripos($message,“http:/”)>-1 | stripos($message,“https:/”)>-1)
或if(preg_-match(“^https:/”,$message))
((stripos($message,“http:/”)| |(stripos($message,“https:/”))with$message='hTTPs://foo.com'
为false
,因为语句为false | | 0
=>false!==错误
=>错误
。