[英]strpos not working as expected, what am i doing wrong?
我試圖按照php.net上的strpos()的示例進行操作 ,但它似乎沒有按我的預期工作。 它將繼續打印其他情況“不在這里”。
$href = "[!--\$testUrl('testlink','754')--]";
dpm($href);
$search_wcm = 'testUrl';
$pos_wcm = strpos($search_wcm, $href);
if ($pos_wcm !== false) {
dpm('here');
} else {
dpm('not here');
}
注意:dpm是Drupal函數,僅在Drupal站點的消息區域中顯示信息。 可以將其視為帶有樣式的“回聲”或“印刷”。
順序錯誤,第一個參數應為要搜索的字符串
$pos_wcm = strpos($href, $search_wcm);
在手冊中,您的論點倒退了:
http://us2.php.net/manual/zh/function.strpos.php
mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )
strpos($href,$search_wcm)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.