开发者

preg_match differences in PHP 5.3.2 vs. PHP 5.2.1

开发者 https://www.devze.com 2023-03-03 20:32 出处:网络
Not much of a PHP/regex guy, but am puzzled as to why some functionality in a PHP Web framework has stopped working since moving to Ubuntu 10.04 LTS (PHP 5.3.2) from Ubuntu 8.04 (PHP 5.2.1).

Not much of a PHP/regex guy, but am puzzled as to why some functionality in a PHP Web framework has stopped working since moving to Ubuntu 10.04 LTS (PHP 5.3.2) from Ubuntu 8.04 (PHP 5.2.1).

Using xdebug and remote debugging, I was able to step through to a function in a GD lib开发者_JAVA技巧rary that checks to see if the file in question has a mime type that can thumbnailed:

function liberty_gd_can_thumbnail_image( $pMimeType ) {
$ret = FALSE;
if( !empty( $pMimeType )) {
    $ret = preg_match( '/^image/i', $pMimeType );
}
return $ret;
}    

I've confirmed that the value of $pMimeType is "i" and changing that line to $ret = true; resolves the issue, but am unsure as to why that would not work now. Hopefully someone with better regex/PHP skills can assist here.


This code is looking for a MIME type that begins with image, e.g. image/gif or image/jpeg. If $pmimeType is "i" then that legitimately fails the test. i is not a valid MIME type, let alone an image MIME type.

I doubt there's anything wrong with the regex matching. I'd look instead at where this bogus i MIME type is coming from.

0

精彩评论

暂无评论...
验证码 换一张
取 消