#25667 [Opn->Ver]: Strange switch-case behaviour

From: Date: Fri, 26 Sep 2003 08:37:35 +0000
Subject: #25667 [Opn->Ver]: Strange switch-case behaviour
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-48128@lists.php.net to get a copy of this message
ID: 25667 Updated by: sniper@php.net Reported By: zeug at delirium dot ch -Status: Open +Status: Verified Bug Type: Scripting Engine problem Operating System: Linux 2.4.20-3-386 -PHP Version: 4.3.3 +PHP Version: 4.3.4-dev, 5.0.0b2-dev Previous Comments: ------------------------------------------------------------------------ [2003-09-26 04:34:08] zeug at delirium dot ch Description: ------------ Hi there This is a very minor bug concerning the structure of a source code rather than its functionality. It's been dealt with in Bug #13387, yet the case was closed back then when it seems to have been fixed in 4.2.0-dev. It's back in 4.3.3. Here are some examples: Example 1, okay: <?php switch ($var): ?> <?php case 1: ?> <?php dothis() ?> <?php endswitch ?> Example 2, okay: <?php switch ($var) { ?> <?php case 1: ?> <?php dothis() ?> <?php } ?> Example 3, syntax error: <?php switch ($var): ?> <?php case 1: ?> <?php dothis() ?> <?php endswitch ?> The parser doesn't seem to like whitespace in HTML between switch and case. When mixing PHP and HTML code, the syntax in example 3 can improve readablility. Reproduce code: --------------- <?php $var = 1 ?> <?php switch ($var): ?> <?php case 1: ?> <?php print $var ?> <?php endswitch ?> Expected result: ---------------- 1 Actual result: -------------- Parse error: parse error, expecting T_ENDSWITCH' or T_CASE' or `T_DEFAULT' in .../test.php on line 4 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25667&edit=1

« previous php.bugs (#48128) next »