dpb56083
2011-02-12 14:01
浏览 83
已采纳

如何从wordpress主题的functions.php修复错误“警告:split()[function.split]:REG_EMPTY”?

Using tanzaku in wordpress and get this error

Warning: split() [function.split]: REG_EMPTY in /public/wp-content/themes/tanzaku/functions.php on line 232

Line 232 in functions.php:

else {
    // ... or get original size info.
    $upload_path = trim( get_option('upload_path') );
    $mark = substr(strrchr($upload_path, "/"), 1); // default mark is 'uploads'
    $split_url = split($mark, $img_url);
    if ($split_url[1] != null) {
        $img_path = $upload_path . $split_url[1];
        list($w, $h) = @getimagesize($img_path);
    }
}

How do I fix this error "Warning: split() [function.split]: REG_EMPTY " from functions.php of wordpress theme?

图片转代码服务由CSDN问答提供 功能建议

在wordpress中使用tanzaku并收到此错误

警告:split()[function.split]:第232行/public/wp-content/themes/tanzaku/functions.php中的REG_EMPTY

第232行 functions.php:

  else {
 // ...或获取原始大小信息。
 $ upload_path = trim(get_option('upload_path')); 
  $ mark = substr(strrchr($ upload_path,“/”),1);  //默认标记为'uploads'
 $ split_url = split($ mark,$ img_url); 
 if($ split_url [1]!= null){
 $ img_path = $ upload_path。  $ split_url [1]; 
 list($ w,$ h)= @gegreize($ img_path); 
} 
} 
   
 
 

我如何 修复此错误“警告:split()[function.split]:REG_EMPTY”来自wordpress主题的functions.php?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douzhi3105 2011-02-12 14:25
    已采纳

    I think the actual problem might be this line:

    $mark = substr(strrchr($upload_path, "/"), 1); 
    

    It searches some url path for the trailing path component, but it would fail for .../dir/upload/ with a traling slash. A convenient alternative in this case would be:

    $mark = basename($upload_path);
    

    This is unlikely to ever be empty, thus eschewing the failing expode or split afterwards. (The string splitting is a suboptimal approach too.)


    A complete workaround might be to also replace the $split_url = split($mark, $img_url); with something like:

    preg_match("#$mark(/.+)$#", $img_url, $split_url);
    

    This will ensure the correct format of the $img_url and return the correct image filename path, or otherwise fail without error if it doesn't match.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题