관련 질문 중 몇 가지를 살펴보고 문제를 볼 수없는 것 같습니다!함수 내에서 함수 호출
다음 두 함수는 내 함수 파일 내에 포함되어 있으며 check_orientation 함수를 사용하여 display_months_news 함수에 배율을 반환 할 수없는 것으로 나타났습니다.
나는 정말 분명히 뭔가를 놓친 것 같아.
display_news 내가 누락 어리석은 실수를 지적 누구든지 사전에
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;
} }}
감사를
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 기능!
check_orientation4의 세 번째 줄에서'$ imgurls'가 NULL이 될 수 있습니까? – Arjen
$ imgurl은 분명히 값을 보유하고 있으며 check_orientation에 전달되는 것을 막을 수는 없으므로 그 문제는 의심 스럽습니다 – Xand94
'$ imgurls'가 전역 변수로 선언되지 않은 경우이 경우 –