我已经浏览了几个相关的问题,似乎看不出这个问题!
以下两个函数都在我的函数include文件中,由于某种原因,我似乎无法使用check_orientation函数将scale返回到display_months_news函数。
我很确定我真的很遗憾。
display_news函数
function display_months_news()
{
//header('Content-type: image/jpeg');
$year = date("y");
$year = "20" .$year;
$month = date("m");
if ($month) {
switch ($month){
case "01": $month = "January"; break;
case "02": $month = "February"; break;
case "03": $month = "March"; break;
case "04": $month = "April"; break;
case "05": $month = "May"; break;
case "06": $month = "June"; break;
case "07": $month = "July"; break;
case "08": $month = "August"; break;
case "09": $month = "September"; break;
case "10": $month = "October"; break;
case "11": $month = "November"; break;
case "12": $month = "December"; break;
}
} else {
echo '<p>The date field is empty.</p>';
}
$nowdate = $month." ".$year;
$result = mysql_query("SELECT * FROM news ORDER BY sqldate DESC LIMIT 6") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
global $imgurl;
$imgurl = $row['img1'];
check_orientation4($imgurl);
$comcount = comment_count($row['nid']);
if ($comcount == NULL) {$comcount = 0;}
echo '<div class="news-preview-container">';
echo '<div class="news-preview-container-date">';
echo "<P>" .$row['mmonth']. " ".$row['dday']. ", " .$row['yyear']. "</p><BR>";
echo '</div>';
echo '<div class="news-preview-container-title">';
echo "<p><a href='article.php?id=" .$row['nid']."'>" .$row['title']."</a></p><BR>";
echo '</div>';
echo '<div class="news-preview-container-inner">';
echo '<div class="news-preview-container-text">';
echo '<p>'.ShortenText($row['body']).'</p>';
echo '</div>';
echo '<div class="news-preview-container-image"><img src="'.$imgurl.'"'.$scale.'"></div><BR></div>';
echo '<div class="news-preview-container-bottombar">Posted in '.$row[tag].' / '.$comcount.' Comments</div>';
echo '</div>';
}
}
和check_orientation函数
function check_orientation4($imgurls){
if ($imgurls == NULL){ echo ""; }
else {
$imgurlshrunk = NULL;
$maxsize = 120;
$filename = NULL;
$height = NULL;
$width = NULL;
$scale = NULL;
$imgurlshrunk = $imgurls;
$filename = basename($imgurlshrunk);
$filename = "admin/uploads/" . $filename;
list($width,$height,$type,$attr) = getimagesize("$filename");
$wRatio = $maxsize / $width;
$hRatio= $maxsize / $height;
global $scale;
if ( ($width <= $maxsize) && ($height <= $maxsize))
{
$scale = "";
return $scale;
}
elseif ( ($wRatio * $height) < $maxsize)
{
$scale = "width = '100%'";
return $scale;
}
elseif ($height == NULL)
{
echo "empty height";
}
else
{
global $height;
$scale = "height = '100%'";
return $scale;
} }}
提前感谢任何人指出我错过的愚蠢错误!
答案 0 :(得分:5)
您不会将check_orientation4($imgurl);
的结果存储在任何地方。尝试将该行更改为:
$scale = check_orientation4($imgurl);
答案 1 :(得分:2)
您没有使用check_orientation4
的返回值执行任何操作答案 2 :(得分:2)
您没有将check_orientation4的返回值分配给任何内容。
check_orientation4($imgurl);
应该是
$scale = check_orientation4($imgurl);
答案 3 :(得分:2)
你不应该把规模归还给某种变量吗?现在你刚刚运行该功能。你应该做点什么:
$toScale = check_orientation4($imgurl);
答案 4 :(得分:0)
因为您要从check_orientation4中丢弃返回值,或许?