RE: [PHP] problems with switch()
| From: | J.R. Lillard | Date: | Sat, 08 Jul 2000 01:05:46 +0000 |
| Subject: | RE: [PHP] problems with switch() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5496@lists.php.net to get a copy of this message | ||
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