|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-08-29 08:42 UTC] k_oss30 at hotmail dot com
hi!
i noticed a problem with nested if...then...else s
Example:
if ($A==1):
if ($B==2) DoThis();
if ($C==3) DoThat();
else:
DoSomething;
endif;
in this case - the 'else:' on thr 4th line is regarded as an 'else' continuing from the 'if' on the 3rd line.
this generates a parser error.
this may cause confusion to some of you (it did to me) but the workaround is this:
if ($A==1) {
if ($B==2) DoThis();
if ($C==3) DoThat();
} else {
DoSomething;
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 14:00:02 2025 UTC |
It's not really a bug, but a side-effect of the old syntax. The new one, with { } does not have this problem, and that's the recommended syntax anyways. I'll mark this one as bogus. Derick