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

如何从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?

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案