Using a variable outside of the while loop (scope)

后端 未结 1 1942
误落风尘
误落风尘 2020-12-02 00:29

Small problem regarding scope in PHP, I can\'t seem to call the variable $report outside of the while loop. I have tried various things, including return. This

相关标签:
1条回答
  • 2020-12-02 00:42

    You could try to define the variable before the loop, e.g.

    $report = "";
    while ($row = mysql_fetch_array($result)) {
        $report .= "a"."b".$row["prevDOCid"]+1;
    }
    echo $report;
    

    I hope this helps you!

    Edit Use .= not +=

    0 讨论(0)
提交回复
热议问题