note 118761 added to control-structures.for
| From: | cherwanoatyadotru | Date: | Mon, 01 Feb 2016 07:18:10 +0000 |
| Subject: | note 118761 added to control-structures.for | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204819@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 72.52.91.14
Probable Submitter: 46.39.238.100
----
Manual Page -- http://php.net/manual/en/control-structures.for.php
Edit -- https://master.php.net/note/edit/118761
Del: integrated -- https://master.php.net/note/delete/118761/integrated
Del: useless -- https://master.php.net/note/delete/118761/useless
Del: bad code -- https://master.php.net/note/delete/118761/bad+code
Del: spam -- https://master.php.net/note/delete/118761/spam
Del: non-english -- https://master.php.net/note/delete/118761/non-english
Del: in docs -- https://master.php.net/note/delete/118761/in+docs
Del: other reasons-- https://master.php.net/note/delete/118761
Reject -- https://master.php.net/note/reject/118761
Search -- https://master.php.net/manage/user-notes.php