本文介绍了PHP的getimagesize与变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用getimagesize
函数获取图像的高度和高度.我正在从数据库中提取图像URL. (字段ProjectURL
包含一行,例如xxx.jpg
).但是我遇到了错误.
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
). However I'm getting an error.
代码:
$testing = "projects/'.$row['ProjectURL'].'";
list($width, $height, $type, $attr) = getimagesize($testing);
echo "Image width " .$width;
echo "<br />";
echo "Image height " .$height;
错误:
推荐答案
这是因为您混合使用单引号和双引号...
it's because you are mixing single and double quotes...
这应该没问题:
$testing = "projects/" . $row['ProjectURL'];
list($width, $height, $type, $attr) = getimagesize($testing);
echo "Image width " . $width;
echo "Image height " . $height;
您可能还已经注意到,我删除了 echo"; ...这个没用了:)
You might also have noticed that I removed the echo "";... this one was useless :)
这篇关于PHP的getimagesize与变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!