From:             [EMAIL PROTECTED]
Operating system: Linux (RedHat 6.2)
PHP version:      4.0.4pl1
PHP Bug Type:     Scripting Engine problem
Bug description:  Switch statement sensible for white-space

The following script gave a parse error:

<? switch($var): ?>
  <? case "alpha": ?>
    <p>Alpha</p>
  <? break; ?>

  <!-- ... -->

<? endswitch; ?>

Parse error: parse error, expecting `T_CASE' or `T_DEFAULT' or `'}'' in 
<my-path>/bug.php on line 2

First I thought that this was really a bug, but then, while typing this report I 
realized that non-PHP-mode characters (like the two spaces) probably are converted to 
an "echo" instruction, so the PHP-parser sees something like the following code:

  switch($var):
  echo '  ';
  case "alpha":
    echo '<p>Alpha</p>';
    break;
  endswitch;

The parser doesn't expect anything (but PHP-mode white-space) to come between the ':' 
on line 1 and 'case' on line 3 and therefore reports parse error. Right?

For the sake of "pretty-scripting", I would like this to change, but at the same time, 
now that I understand why the parser complains, I'm not sure if it should be changed...



-- 
Edit Bug report at: http://bugs.php.net/?id=11447&edit=1



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to