search

Home  >  Q&A  >  body text

for loop assignment problem?

http://www.php.cn/code/5179.html

In this tutorial, the information from the for loop is assigned to the session, and the information is looped out like this Only one number is obtained;


for($i=0;$i<4;$i ){
$color=imagecolorallocate($image,rand(0,255),rand(0,255 ),rand(0,255));
$x=100/4*$i 7;
$y=rand(0,20);
$size=6;
$content=rand (0,9);
$yzxx="$content";
imagestring($image,$size,$x,$y,$content,$color);
}
$_SESSION ['yzxx']=$yzxx;
var_dump($_SESSION);

杜文涛杜文涛2645 days ago1261

reply all(1)I'll reply

  • 路过

    路过2017-10-10 16:30:08

    $yzxx .= "$content"; You are missing a "." in front of the equal sign

    reply
    1
  • 杜文涛

    Thank you. Newbies are not very good at it.

    杜文涛 · 2017-10-10 19:35:48
    杜文涛

    I took a look at the tutorial. I guess everything was written wrong in the tutorial.

    杜文涛 · 2017-10-10 19:40:29
    路过

    Who is not a newbie? come on

    路过 · 2017-10-11 08:41:45
  • Cancelreply