我有一个函数如下,但我得到警告的$tab变量,说它没有定义.我该如何定义它并且不再收到此警告?
<?php
/*** suggested articles as random ***/
function doArticle_suggested_small_horizontall($articleid,$title,$photo,$parentid,$catid,$altdescription) {
$tab .= "<table width=150 cellspacing=5 style=border: 1px solid #0066ff align=right>\n";
$tab .= "<tr>\n";
$tab .= "<td align=center bgcolor=#ffffff><a href='../artandculture/adetails.php?articleid=$articleid&parentid=$parentid&catid=$catid'>
<img src='../images/simage/$photo' border='0' alt='$altdescription'></a></td>\n";
$tab .= "</tr>\n";
$tab .= "<tr align=right width=150 height=80 border=0 style=border: 1px solid #ffffff>\n";
$tab .= "<td width=110 align=right dir='rtl' border=0 style=border: 1px solid #ffffff ><p class=articletitlenounderline><a href='../artandculture/adetails.php?articleid=$articleid&parentid=$parentid&catid=$catid'><strong>$title </strong></p></a></td>\n";
$tab .= "</tr>\n";
$tab .= "</table> <p> <hr class='hr99' ></hr></p>";
return $tab;
}
$tab = "";
?>
Run Code Online (Sandbox Code Playgroud)
您需要$tab在函数的开头定义.
更换 $tab .= "<table width=15 ....
同 $tab = "<table width=15....
或者你可以添加$tab = "";为函数的第一行,现在你要在你应该删除的函数之外定义它.