我有一个使用strpos()方法的插件,在一个站点上我得到了这个错误
Warning: strpos() [function.strpos]: Empty delimiter. in /home/mysite/public_html/wp-includes/compat.php on line 55你知道可能的原因是什么吗?
摘自compat.php
if (!function_exists('stripos')) {
function stripos($haystack, $needle, $offset = 0) {
return strpos(strtolower($haystack), strtolower($needle), $offset);
}
}我的代码...
function myFunction($thePost)
{
$theContent = $thePost->post_content;
$myVar1 = array();
preg_match_all('/<a\s[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU',$theContent,$myVar1);
$myVar2 = 0;
foreach ($myVar1[1] as $myVar3)
{
$myVar4 = $myVar1[2][$myVar2];
$myVar5 = FALSE;
$myVar6 = get_bloginfo('wpurl');
$myVar7 = str_replace('http://www.','',$myVar3);
$myVar7 = str_replace('http://','',$myVar7);
$myVar8 = str_replace('http://www.','',$myVar6);
$myVar8 = str_replace('http://','',$myVar8);
if (strpos($myVar3,'http://')!==0 || strpos($myVar7,$myVar8)===0) return TRUE;
$myVar2++;
}
return FALSE;
}发布于 2010-12-07 12:42:23
将一个空字符串作为第二个参数传递给Wordpress的stripos()实现(而不是上面粘贴的代码)。
我能问一下你为什么要用PHP4吗?
发布于 2014-05-06 09:04:37
尝试在变量的上添加双引号
更改此行: if (strpos($myVar3,'http://')!==0 || strpos($myVar7,$myVar8)===0)返回TRUE;
into: if (strpos(".$myVar3.",'http://')!==0 || strpos(".$myVar7.",".$myVar8.")===0)返回TRUE;
https://stackoverflow.com/questions/4373301
复制相似问题