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!==错误
=>
错误