For PHP recursive query, the parent class can be output by echo and cannot return & lt ;? Phpinclude_once (".. /conn. php "); function & nbsp; SontoFather ($ I) & nbsp; {& nbsp; $ SQL & nbsp ;=& nbsp;" SELECT & nbsp; 'parent _ I: Ask for PHP to recursively query the parent class, which can be output by echo and cannot be returned.
include_once("../conn.php");
function SontoFather($i)
{
$sql = "SELECT `parent_id`,`cate_name` FROM `dlbz_gcategory` WHERE `cate_id`=".$i;
echo $sql;
echo '
';
$result = mysql_query($sql);
$row=mysql_fetch_row($result);
//echo $row[1];
if($row[0]!=0)
{
$i = $row[0];
//echo $i;
//echo $row[1];
SontoFather($i);
}
else
{
echo $row[1];
//$j=$row[1];
return $row[1];
}
}
echo SontoFather(3);
echo SontoFather(450);
?>
Echo SontoFather (3); this sentence can be output normally. that is, the parent class has no recursion problem. you can return the returned value or echo the output;
Echo SontoFather (450); the return output is not normal, but can be echo output.
Php? Return ?? Recursion? Echo
------ Solution --------------------
16 rows
SontoFather ($ I );
Change
Return SontoFather ($ I );