Bug #13026: if...then...else problem

From: Date: Wed, 29 Aug 2001 12:42:10 +0000
Subject: Bug #13026: if...then...else problem
Groups: php.dev 
Request: Send a blank email to php-dev+get-64592@lists.php.net to get a copy of this message
From:             k_oss30@hotmail.com
Operating system: Red Hat Linux 7.0
PHP version:      4.0.6
PHP Bug Type:     Unknown/Other Function
Bug description:  if...then...else problem

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 bug report at: http://bugs.php.net/?id=13026&edit=1



Thread (2 messages)

« previous php.dev (#64592) next »