Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
搜索脚本中的PHP IP检测_Php_Html - Fatal编程技术网

搜索脚本中的PHP IP检测

搜索脚本中的PHP IP检测,php,html,Php,Html,我有一个PHP脚本,可以检测用户的IP地址,并在搜索脚本中搜索某个词时显示该地址。当用户搜索包含“what is my ip”字样的内容时,将显示他们的ip。我的问题是,;如果用户要搜索“what's my ip address”(我的ip地址是什么)或使用大写字母进行搜索,我该如何做同样的事情 我希望你能理解我的问题。以下是我的PHP代码: if(strpos($_GET['q'],'what is my ip')===0){ echo "Your IP address is <

我有一个PHP脚本,可以检测用户的IP地址,并在搜索脚本中搜索某个词时显示该地址。当用户搜索包含“what is my ip”字样的内容时,将显示他们的ip。我的问题是,;如果用户要搜索“what's my ip address”(我的ip地址是什么)或使用大写字母进行搜索,我该如何做同样的事情

我希望你能理解我的问题。以下是我的PHP代码:

if(strpos($_GET['q'],'what is my ip')===0){
    echo "Your IP address is <b>{$_SERVER['REMOTE_ADDR']}</b><br><a href='http://www.wikipedia.org/wiki/IP_address'>What is an IP address?</a>";
}
if(strpos($\u GET['q'],'what is my ip')==0){
echo“您的IP地址是{$\u服务器['REMOTE\u ADDR']}
”; }
如果您不想让案例变得重要,请使用忽略案例的
strpos
变体(case-*i*nsensitive):


对于大写部分-只需将查询字符串转换为小写或大写。这使您可以控制字符串

if(stripos($_GET['q'],'what is my ip')===0){
      ^