note 118761 deleted from control-structures.for by salathe
| From: | salathe@php.net | Date: | Mon, 01 Feb 2016 12:51:56 +0000 |
| Subject: | note 118761 deleted from control-structures.for by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-204829@lists.php.net to get a copy of this message | ||
Note Submitter: cherwano at ya dot ru
----
Please notice, that "for" (in 5.x at least) can't initialize variables in the middle:
<?php
for($i = 0; ($k < $s) || ($k = $s); $l++)
{//does not work, drop at first check - $k and $s is not initialised
/*some code here*/
} //press [alt]+[0] to hide listing.
?>
<?php
$k=0; $s=0; $l=0;
for ($i = 0; ($k < $s) || ($k = $s); $l++)
{//Is ok. Even if $i is used only to enter the cycle.
/*some code here*/
} //press [alt]+[0] to hide listing.
?>
I don't know why you may try to use this, but now you will know why it may not work.