[PHP-DEV] Bug #13026 Updated: if...then...else problem From: derick <email protected>
Date: 08/29/01

ID: 13026
Updated by: derick
Reported By: k_oss30 <email protected>
Old Status: Open
Status: Bogus
Bug Type: Unknown/Other Function
Operating System: Red Hat Linux 7.0
PHP Version: 4.0.6
New Comment:

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

Previous Comments:
------------------------------------------------------------------------

[2001-08-29 08:42:10] k_oss30 <email protected>

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;
}

------------------------------------------------------------------------

Edit this bug report at http://bugs.php.net/?id=13026&edit=1

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>