RE: [PHP] problems with switch()

From: Date: Sat, 08 Jul 2000 01:15:12 +0000
Subject: RE: [PHP] problems with switch()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5499@lists.php.net to get a copy of this message
no i do not. it is my understanding that if you're only putting one command between the <? and ?> tags, you don't need the trailing semicolon. i've had no problems in that sense either. so: <? $x = 1 ?> <? $y = 1 ?> is the same as: <? $x = 1; $y = 1; ?> On Fri, 7 Jul 2000, August Zajonc wrote: > Date: Fri, 7 Jul 2000 21:08:12 -0400 > From: August Zajonc <augustz@bigfoot.com> > To: J.R. Lillard <jr@hyphen.org> > Cc: Php-General <php-general@lists.php.net> > Subject: RE: [PHP] problems with switch() > > You have a semi colon after the first $x = 1 in real life? > > > > -----Original Message----- > > From: J.R. Lillard [mailto:jr@hyphen.org] > > Sent: Friday, July 07, 2000 9:06 PM > > To: August Zajonc > > Cc: php-general@lists.php.net > > Subject: RE: [PHP] problems with switch() > > > > > > that doesn't work either. something like this will generate the same > > error: > > > > <html> > > <body> > > <? $x = 1 ?> > > <? switch ($x) { ?> > > <? > > case 1: > > echo "x = 1"; > > break; > > default: > > echo "x != 1"; > > ?> > > <? } ?> > > </body> > > </html> > > > > On Fri, 7 Jul 2000, August Zajonc wrote: > > > > > Date: Fri, 7 Jul 2000 20:47:05 -0400 > > > From: August Zajonc <augustz@bigfoot.com> > > > To: J.R. Lillard <jr@hyphen.org>, php-general@lists.php.net > > > Subject: RE: [PHP] problems with switch() > > > > > > default: may not like having no statement folloring it. What about > > > adding echo ""; on the next line? > > > > > > August > > > > > > > > > > -----Original Message----- > > > > From: J.R. Lillard [mailto:jr@hyphen.org] > > > > Sent: Friday, July 07, 2000 8:22 PM > > > > To: php-general@lists.php.net > > > > Subject: [PHP] problems with switch() > > > > > > > > > > > > i'm running php 4.0. most of my code looks something like this: > > > > > > > > <html> > > > > <body> > > > > <? $x = 1 ?> > > > > <? if ($x == 1) { ?> > > > > x = 1 > > > > <? } else { ?> > > > > x != 1 > > > > <? } ?> > > > > </body> > > > > </html> > > > > > > > > i know that may not be the easiest thing for the parser to > > > > parse, but it's > > > > easier for me to read it. basically i'm going in and out > > of php code > > > > through the block of the if() statement. but if i do > > > > something like this: > > > > > > > > <html> > > > > <body> > > > > <? $x = 1 ?> > > > > <? switch ($x) { ?> > > > > <? case 1: ?> > > > > x = 1 > > > > <? break ?> > > > > <? default: ?> > > > > x != 1 > > > > <? } ?> > > > > </body> > > > > </html> > > > > > > > > i get this error: > > > > > > > > Parse error: parse error, expecting `T_CASE' or > > T_DEFAULT' or '}'' > > > > > > > > referencing the line right after the switch() statement. > > but if i do > > > > this: > > > > > > > > <html> > > > > <body> > > > > <? $x = 1 ?> > > > > <? > > > > switch ($x) { > > > > case 1: > > > > echo "x = 1"; > > > > break; > > > > default: > > > > echo "x != 1"; > > > > } > > > > ?> > > > > </body> > > > > </html> > > > > > > > > it works just fine. is there any reason i can't jump in and > > > > out of php > > > > code in the block of a switch() statement? it works just > > > > fine with if()s, > > > > while()s, and for()s. > > > > > > > > -jr > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > > For additional commands, e-mail: php-general-help@lists.php.net > > > > To contact the list administrators, e-mail: > > > > php-list-admin@lists.php.net > > > > > > > -jr > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: > > php-list-admin@lists.php.net > -jr

« previous php.general (#5499) next »