Define a variable in a function php -


this question has answer here:

i have function below warning $tab variable says not defined. how can define , not receive warning anymore?

<?php /*** suggested articles 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 = ""; ?> 

you need define $tab @ beginning of function.

replace $tab .= "<table width=15 ....

with $tab = "<table width=15....

or add $tab = ""; first line of function, defining outside function should remove.


Comments