php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #36877 comma in expr1 undocumented in for ($i=1,$n=10;
Submitted: 2006-03-27 21:37 UTC Modified: 2007-01-23 13:57 UTC
From: php-bugs at t43 dot mine dot nu Assigned: colder (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: na
Private report: No CVE-ID: None
 [2006-03-27 21:37 UTC] php-bugs at t43 dot mine dot nu
Description:
------------
Documentation issue:
The C-like clause for expr1 in 
for ($i=0, $n=10; ...) 
is accepted but not documented.
The corresponding C-like clause
$i=0, $j=1; outside a for is flagged as an error.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-27 21:52 UTC] php-bugs at t43 dot mine dot nu
It is also undocumented for expr3.
 [2006-03-28 17:46 UTC] colder@php.net
Note that the use of multiple expressions in expr3 was already mentionned in example4.

Anyway, here is a suggestion of a possible improvement:

http://patches.colder.ch/control-structures-for.patch

Thanks in advance.
 [2006-03-30 04:10 UTC] simp@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

thanks for the patch
 [2006-03-30 09:29 UTC] php-bugs at t43 dot mine dot nu
I thank you sincerely for the answer.
 [2006-03-30 11:33 UTC] arpad@php.net
You can use a comma in expr2 too, it's equivalent to || but much lower in precedence.
 [2006-03-30 16:30 UTC] colder@php.net
Thanks for the note arpad, 

here is the updated patch:

http://patches.colder.ch/control-structures-for-2.patch
 [2006-03-30 19:08 UTC] php-bugs at t43 dot mine dot nu
IMHO
(1) should only be documented what is intended. ZEND should say about comma in expr2 before it makes it into the manual. Such deviation from C should be intentional if at all.
(2) in C++, by 5.2 of its definition, only assigments can be comma-sequenced. Simple boolean expressions are not yet assignments. The value of a sequenced expression is the value of the last assigment, not an OR of them. 
(3) it would be more logical to give comma in expr-2 the meaning of AND: continue while (data available AND buffer available). But better nothing.
 [2006-03-30 19:18 UTC] php-bugs at t43 dot mine dot nu
It is however true that it executes as arpad described.
 [2007-01-23 13:57 UTC] colder@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

fixed for months :]
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Aug 06 22:00:03 2025 UTC