note 27276 added to functions
| From: | mentor at bassment dot be | Date: | Sat, 30 Nov 2002 00:08:15 +0000 |
| Subject: | note 27276 added to functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40135@lists.php.net to get a copy of this message | ||
Hi ..
I thought it was important to put the following up here :
apparently, functions and while loops can become quite a mess, when you want to output paired
variables to a browser
PHP (maybe others too) will first execute all the function calls, before starting to run through the
while loop
An example :
while ($statement) {
$output .= "&var1=" .$var1 ;
$output .= "&var2=" .the_function($var2) ;
$output .= "&var3=" .$var3 ;
echo $output ;
}
will return you the following :
result_of_the_function_on_parameter
&var1=var1&var2=&var3=var3
Note that the var2 in this short example is written as output before the rest of the variables -
which indicates that the functions are being executed first in a while loop, and only then does the
rest of the story kick in ...
Would anybody be able to explain the logic of this .... ?
I suppose there is a workaround that could be found, but it seems weird ...
Cheers
mentor
--
http://www.php.net/manual/en/functions.php
http://master.php.net/manage/user-notes.php?action=edit+27276
http://master.php.net/manage/user-notes.php?action=delete+27276
http://master.php.net/manage/user-notes.php?action=reject+27276