开发者

PHP getimagesize with variable

开发者 https://www.devze.com 2023-02-06 04:06 出处:网络
I\'m trying to use the getimagesize function to get the height and with of an image. I\'m pulling the image URL from a database. (The field ProjectURL contains a line such as xxx.jpg). H开发者_开发知识

I'm trying to use the getimagesize function to get the height and with of an image. I'm pulling the image URL from a database. (The field ProjectURL contains a line such as xxx.jpg). H开发者_开发知识库owever I'm getting an error.

Code:

$testing = "projects/'.$row['ProjectURL'].'";
    list($width, $height, $type, $attr) = getimagesize($testing);
    echo "Image width " .$width;
echo "<br />";
echo "Image height " .$height;

Error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING


it's because you are mixing single and double quotes...

this should be ok:

$testing = "projects/" . $row['ProjectURL'];
list($width, $height, $type, $attr) = getimagesize($testing);
echo "Image width " . $width;
echo "Image height " . $height;

You might also have noticed that I removed the echo "";... this one was useless :)

0

精彩评论

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