为什么 !gt 不等于带有 stripos() 函数的 !gt?
Why doesn't !gt equal to !gt with the stripos() function?
我在 php 中遇到了字符串比较的问题,我已经通过互联网进行了研究但无济于事。那么轮到我提问了:
以下是我比较两个字符串的代码,一个来自我的数据库,一个来自 irc 聊天。问题是这段代码无法正确比较
if('!gt' == $command)
^这行不通,也行不通:
if(stripos('!gt', $command) === 0){
echo "This is the correct command<br>";
privmsg($channel, $GLOBALS['commands'][$i]['message']);
}
IRC 输入($命令)= !gt
我的问题最终是:为什么 !gt 不等于 !gt 与 stripos()函数?
似乎我在字符串中得到了一些额外的字符,所以我不得不使用:
trim(string)
删除多余的字符。
非常感谢@rizier123、@MarkBaker 和@AbraCadaver 的帮助:D
我在 php 中遇到了字符串比较的问题,我已经通过互联网进行了研究但无济于事。那么轮到我提问了:
以下是我比较两个字符串的代码,一个来自我的数据库,一个来自 irc 聊天。问题是这段代码无法正确比较
if('!gt' == $command)
^这行不通,也行不通:
if(stripos('!gt', $command) === 0){
echo "This is the correct command<br>";
privmsg($channel, $GLOBALS['commands'][$i]['message']);
}
IRC 输入($命令)= !gt
我的问题最终是:为什么 !gt 不等于 !gt 与 stripos()函数?
似乎我在字符串中得到了一些额外的字符,所以我不得不使用:
trim(string)
删除多余的字符。
非常感谢@rizier123、@MarkBaker 和@AbraCadaver 的帮助:D