小编Ani*_*Ani的帖子

strpos/stripos(严格比较)失败

我目前有以下strpos/stripos(尝试过两者,不会改变结果),用于标记论坛帖子中的某些针.

if (stripos($row->message, (string)$commit) !== false) {
  // Do stuff
}
Run Code Online (Sandbox Code Playgroud)

在大多数情况下,当haystack($ row-> message)包含needle($ commit)(使用强制转换,因为$ commit可以是一个int)strpos/stripos返回false时,东西大多数工作正常.

例如:

$test = stripos($row->message, (string)$commit);
Run Code Online (Sandbox Code Playgroud)

非工作场景的一个示例是:

// (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." …
Run Code Online (Sandbox Code Playgroud)

php strpos stripos

2
推荐指数
1
解决办法
218
查看次数

标签 统计

php ×1

stripos ×1

strpos ×1