strpos:2个结果,但有2个相似的字符串


strpos: 2 results but 2 similar strings

我不知道该怎么办。

2个参数:第一个:

0 D:/Google Drive/Dokument/Programmierung/Webentwicklung/htdocs/BeLL__Website_fuer_Filfestive/php/checkSession.php(6):Phip/Engine/Login->checkSession()1 D:/Google Drive/Dokument/Programmierung/Webentwicklung/htdocs/BeLL__Webseite_fuer_Filfestive/login.php(3):include('D:/Googe Drive…'){main}

第二:

D:/Google Drive/Dokument/Programmierung/Webentwicklung/htdocs/BeLL__Website_fuer_Filmfestival/php/Phip/Engine/Login/Login.php

php函数

private function clean( $clean ) {
    $clean = str_replace( '''', '/', $clean );
    if ( !strpos( $clean, 'D:/Google Drive/Dokumente/Programmierung/Webentwicklung/htdocs/BeLL__Webseite_fuer_Filmfestival' )) {
        return  str_replace( 'D:/Google Drive/Dokumente/Programmierung/Webentwicklung/htdocs/BeLL__Webseite_fuer_Filmfestival', '', $clean );
    } 
}

问题:

false:var_dump(!strpos($param1,'D:/Google Drive/Dokument/Programmierung/Webentwicklung/htdocs/BeLL__Website_fuer_Filmfestival'));

true:var_dump(!strpos($param2,'D:/Google Drive/Dokument/Programmierung/Webentwicklung/htdocs/BeLL__Website_fuer_Filmfestival'));

我不能理解,因为这两个字符串中都有这个字符串。。。有人能帮帮我吗?为什么不一样?

非常感谢!我希望你能得到我想要的。

您错误地使用了strpos()

strpos()[查找]干草堆字符串中第一次出现针的数字位置。

更重要的是:

警告:此函数可能返回布尔值FALSE,但也可能返回计算结果为FALSE的非布尔值。有关更多信息,请阅读布尔型部分。使用===运算符测试此函数的返回值。

所以像一样使用它

strpos($needle, $haystack) === false // true if needle is not contained in haystack
strpos($needle, $haystack) !== false // true if needle is contained in haystack