这是错误:
对于:PHP 5.2+
警告:strpos()[function.strpos]:行445上/helper.php中的空分隔符
这是该行上的代码:
if($src = $img->getAttribute('src') AND strpos($src,$fgParams->get('base')) === false) { // prevents repeat processing
EgivaUtility::profiling('Processing Image SRC: '.$src);
// fix rel paths
$src = EgivaUtility::encode_url(EgivaUtility::makeAbsUrl($origLink,$src));
if($image_details = @getimagesize($src) AND !in_array($image_details[0],array(1,2)) AND !in_array($image_details[1],array(1,2))) {
EgivaUtility::profiling('Image Details: '.print_r($image_details,true));
$title = $img->getAttribute('title');
$alt = $img->getAttribute('alt');
if($fgParams->get('save_img')) { // consider restoring the JPath::clean()
// find image name and extension
$name = $title ? EgivaUtility::stringURLSafe($title) : EgivaUtility::stringURLSafe($alt);
preg_match('#[/?&]([^/?&]*)(\.jpg|\.jpeg|\.gif|\.png)#i',$src,$matches);
$ext = isset($matches[2]) ? strtolower($matches[2]) : '';
if(!$name) $name = isset($matches[1]) ? EgivaUtility::stringURLSafe($matches[1]) : md5($src);
unset($matches);
//create image file
$filename = $fgParams->get('name_prefix').$name.$ext;
$filepath = $fgParams->get('savepath').'images'.DS.$filename;
if(!file_exists($filepath)) {
if($contents = EgivaUtility::getUrl($src,$fgParams->get('scrape_type'),'images',$filepath)) {
$saved = true;
//if(EgivaUtility::savefile($contents,$name,$update=false,$header=null,$fgParams->get('savepath').'images')) $saved = true;
}
} else {
$saved = true;
}
if($saved) $img->setAttribute('src', $fgParams->get('srcpath').'images/'.$filename);
} else {
$img->setAttribute('src',$src);
}
EgivaUtility::profiling('Final Image SRC: '.$img->getAttribute('src'));
// $class = $img->getAttribute('class');
// $width = $img->getAttribute('width');
// $height = $img->getAttribute('height');
if(strlen($alt) >= JString::strlen($content['title']) OR !$alt) {
$img->setAttribute('alt',$content['title']);
}
if($fgParams->get('rmv_img_style')) {
$img->removeAttribute('class');
$img->removeAttribute('style');
$img->removeAttribute('align');
$img->removeAttribute('border');
$img->removeAttribute('width');
$img->removeAttribute('height');
}
if($fgParams->get('img_class')) {
$img->setAttribute('class',$fgParams->get('img_class'));
}
$new_img = $dom2->importNode($imgs->item($k),true);
$dom2->appendChild($new_img);
$images[$k] = $dom2->saveHTML();
$dom2->removeChild($new_img);
// hack to avoid encoding problems
$text = preg_replace($regex,'fg_img'.$k,$text,$limit=1);
$replace[$k] = 'fg_img'.$k;
$k++;
} else {
EgivaUtility::profiling('Image Rejected');
$text = preg_replace($regex,'',$text,1);
}
}
}
参考方案
当strpos的第二个参数为空时,会发生此错误。例如,我可以在命令行上轻松模拟此错误:
$ php
<?php
echo strpos("foo", "");
?>
^D
Warning: strpos(): Empty delimiter in - on line 2
在您的代码中,这意味着$fgParams->get('base')
为空。
在代码中添加一些检查,以确保传递给strpos的值有效,并且错误将消失。
php-casperjs获取内部文本 - php我正在为casperjs使用php包装器-https://github.com/alwex/php-casperjs我正在网上自动化一些重复的工作,我需要访问一个项目的innerText,但是我尚不清楚如何从casperjs浏览器访问dom。我认为在js中我会var arr = document.querySelector('label.input…
php:是否有充分的理由引用所有数组键/索引? - php我正在遍历别人的代码,他们总是避免转义其数组键。例如:$ row_rsCatalogsItems [名称]代替$ row_rsCatalogsItems ['名称']因此,我不断地对自己接触的所有事物进行微小的更改,以应对这些惰性。但是现在我想知道这样做是否有很多好处。我得到它会在默认为字符串之前检查常量(我在处理常量时会讨厌php中的行为,因为即使未定义,…
CakePHP将数据传递到元素 - php我的控制器中有以下代码:function index() { $posts = $this->set('posts', $this->Portfolio->find('all')); if (isset($this->params['requested'])) { retur…
phpWord中的粗体,空格和缩进文本 - php我有一些要加粗的文本,与前几段和后几段分开并缩进。我不能让所有三个属性一起工作。这适用于粗体和空格:$section = $phpWord->addSection(); $section->addText( 'Re: Your Application for Post of Security Guard', array(…
PHP数组可以这样做吗? - php可以说;我有一个$ friends数组,其中有2,000个不同的friendID号+我有一个带有10,000 bulletinID号的$ bulletins数组,该$ bulletins数组还将具有另一个值,该ID的用户ID是发布公告条目的用户现在可以获取所有具有与FriendsID数组中的userID匹配的userID的bulletinID号吗?甚至有可能…