开发者

getimagesize not working

I'm trying to get the开发者_C百科 image size but not managing to do it. What could be the problem?

$size = getimagesize("http://getfavicon.appspot.com/http://google.com?defaulticon=1pxgif");

echo $size[0];


I know this is an old thread, but this may help others. There is a php.ini setting, allow_url_fopen, that needs to be turned on in order to access the getimagesize parameter when it is a fully qualified (http://) URL. PHP only throws a warning, so if you have error reporting turned off, you may not see the problem. Also, your server's error log may report that "no suitable wrapper could be found".


It returns an array

<?php
$size = getimagesize("http://getfavicon.appspot.com/http://google.com?defaulticon=1pxgif");

list($width, $height) = $size;
echo "width: $width<br />height: $height";
?>

http://sandbox.phpcode.eu/g/8806e/2

will show exactly things you need


getimagesize() actually returns an array with many informations (not only the size).

Use this:

list($width, $height) = getimagesize(...);
echo "$width $height";

See getimagesize() documentation.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜