我已經瀏覽了幾個相關的問題,看起來似乎無法看到問題!在函數內調用函數
以下兩個函數都在我的函數include文件中,而且由於某種原因,我似乎無法獲得check_orientation函數來將比例返回到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;
} }}
在此先感謝誰指出了愚蠢的錯誤我錯過了!
難道是'$ imgurls'在check_orientation4的第三行是NULL? – Arjen 2011-04-12 13:42:56
$ imgurl明確擁有一個值,並且看不到任何阻止它傳入check_orientation的東西,所以我懷疑這是問題 – Xand94 2011-04-12 13:44:34
如果'imgurls'沒有聲明爲全局變量,則會出現這種情況 – 2011-04-12 13:44:53