php: assignment operator

From: Date: Wed, 07 Aug 2002 00:54:47 +0000
Subject: php: assignment operator
Groups: php.general 
Request: Send a blank email to php-general+get-111452@lists.php.net to get a copy of this message
Thank you. I have another question regarding the same script. In the original code from Wrox "Beginning PHP4" on page 330, they use the assignment operator .= ............................ for($i=0; $i<strlen($counter); $i++) { $image_src=$image_dir. "/" .substr($counter, $i, 1) . ".jpg"; $image_tag_src.="<IMG SRC=\"$image_src\" BORDER=\"0\">"; // assignment operator .= } .................................... why is that? If I was to assign the html string to the variable $image_tag_src without the .= and insert a =, the script continues to run fine since $image_src still contiunes to hold the value of $image_dir. "/" .substr($counter, $i, 1) . ".jpg"; as in... ................................ for($i=0; $i<strlen($counter); $i++) { $image_src=$image_dir. "/" .substr($counter, $i, 1) . ".jpg"; $image_tag_src="<IMG SRC=\"$image_src\" BORDER=\"0\">"; // assignment operator = } ....................................... Please advise. Thanks again, TR ........................................ > > > Damian Harouff <php-lists@cekkent.net> wrote in message > news:70434471116.20020806161330@cekkent.net... > > try this: > > > > $image_tag_str .="<IMG SRC=\"$image_src\" > > BORDER=\"0\">"; > > > > AR> Trying to test a counter using php / MS Windows 98 / Apache with three > .jpg > > AR> files. > > > > AR> They are named: > > > > AR> 1.jpg > > AR> 2.jpg > > AR> 3.jpg > > > > AR> and are stored in a folder called: > > AR> images > > > > AR> which is in the same directory as Counter.txt > > AR> within > > AR> htdocs. > > > > AR> I run the following script but the images do not appear. > > AR> Thanking all in advance. > > AR> Tony Ritter > > AR> ............................................................ > > > > AR> <? > > AR> $counter_file="./Counter.txt"; > > AR> $image_dir="./images"; > > AR> if(!($fp=fopen($counter_file, "r")))die("Couldn't open the > > AR> file"); > > AR> $counter=(int)fread($fp, 20); > > AR> fclose($fp); > > > > AR> $counter++; > > > > AR> for($i=0; $i<strlen($counter); $i++) > > AR> { > > AR> $image_scr=$image_dir."/".substr($counter, $i, 1).".jpg"; > > AR> $image_tag_str.="<IMG SCR=\"$image_src\" > > AR> BORDER=\"0\">"; > > AR> } > > > > AR> echo "You are visitor $image_tag_str"; > > AR> $fp=fopen($counter_file, "w"); > > AR> fwrite($fp,$counter); > > AR> fclose($fp); > > ?>> --

« previous php.general (#111452) next »