Php STRPO/stripos(具有严格比较)失败
我目前有以下strpos/stripos(两者都尝试过,不会改变结果),用于标记论坛帖子中的某些指针Php STRPO/stripos(具有严格比较)失败,php,strpos,stripos,Php,Strpos,Stripos,我目前有以下strpos/stripos(两者都尝试过,不会改变结果),用于标记论坛帖子中的某些指针 if (stripos($row->message, (string)$commit) !== false) { // Do stuff } 不过,在一些情况下,当haystack($row->message)包含needle($commit)时(使用cast是因为$commit可以是int),strpos/stripos返回false 例如: $test = stripos($ro
if (stripos($row->message, (string)$commit) !== false) {
// Do stuff
}
不过,在一些情况下,当haystack($row->message)包含needle($commit)时(使用cast是因为$commit可以是int),strpos/stripos返回false
例如:
$test = stripos($row->message, (string)$commit);
非工作场景的一个示例是:
// (string)$commit
string(7) "818df50"
// $row->message
string(321) "Intro. Crashes as soon as the main menu is shown. Graphics are horribly broken, no fixes have been found as of yet. [attachment=194] Build Used: Pull Request #3333 (0.0.3-5929) -> RPCS3-v0.0.3-2017-08-27-818f50b Side note: States it can display at 1080p, yet it is boxed in 1080p. However, it is fine in 720p."
// $test (strpos/stripos)
bool(false)
// (string)$commit
string(7) "2570911"
// $row->message
string(219) "RPCS3 v0.0.3-3-2570911 Alpha The game doesn't even show its graphics window. [quote] ·F 0:00:34.138812 {PPU[0x1000000] Thread (main_thread) [0x0087c094]} MEM: Access violation writing location 0xcffff2d0 [/quote]" int(15) [2570911]
// $test (strpos/stripos)
int(15) [2570911]
工作场景的一个示例是:
// (string)$commit
string(7) "818df50"
// $row->message
string(321) "Intro. Crashes as soon as the main menu is shown. Graphics are horribly broken, no fixes have been found as of yet. [attachment=194] Build Used: Pull Request #3333 (0.0.3-5929) -> RPCS3-v0.0.3-2017-08-27-818f50b Side note: States it can display at 1080p, yet it is boxed in 1080p. However, it is fine in 720p."
// $test (strpos/stripos)
bool(false)
// (string)$commit
string(7) "2570911"
// $row->message
string(219) "RPCS3 v0.0.3-3-2570911 Alpha The game doesn't even show its graphics window. [quote] ·F 0:00:34.138812 {PPU[0x1000000] Thread (main_thread) [0x0087c094]} MEM: Access violation writing location 0xcffff2d0 [/quote]" int(15) [2570911]
// $test (strpos/stripos)
int(15) [2570911]
我不知道我是否遗漏了一些非常明显的东西,我检查了几次,方法似乎是正确的
注意:我知道有几十种方法可以做到这一点,但在这个特定场景中,我需要这些字符串比较
提前感谢。在您的示例中
// (string)$commit
string(7) "818df50"
// $row->message
string(321) "Intro. Crashes as soon as the main menu is shown. Graphics are horribly broken, no fixes have been found as of yet. [attachment=194] Build Used: Pull Request #3333 (0.0.3-5929) -> RPCS3-v0.0.3-2017-08-27-818f50b Side note: States it can display at 1080p, yet it is boxed in 1080p. However, it is fine in 720p."
// $test (strpos/stripos)
bool(false)
针818df50
不包含在草堆中。干草堆包含一个非常接近的字符串(818f50
),但这不是一个完全匹配的字符串
所以。。。它正在做正确的操作。哦,哈哈,我需要多睡一会儿。检查了好几次,没有注意到这样一个愚蠢的错误。谢谢