php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29304 Parse error with "switch" and html code
Submitted: 2004-07-21 16:17 UTC Modified: 2004-07-21 17:38 UTC
From: devis at witcom dot com Assigned:
Status: Not a bug Package: Compile Failure
PHP Version: 4.3.7 OS: Linux Debian
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: devis at witcom dot com
New email:
PHP Version: OS:

 

 [2004-07-21 16:17 UTC] devis at witcom dot com
Description:
------------
Bug #11447 REOPENED

when ther is html code between "switch" and the first "case" php reports this error: "Parse error: parse error, expecting `T_ENDSWITCH' or `T_CASE' or `T_DEFAULT'"

the problem occurs while indenting html+php code:

<html>
<body>
	<?switch ($a):?>
		<?case 0: echo "zero"; break;?>
		<?default: echo "one"; break;?>
	<?endswitch;?>
</body>
</html>

Reproduce code:
---------------
THIS WORKS:

<html>
<?switch ($a):?>
<?case 0: echo "zero"; break;?>
<?default: echo "one"; break;?>
<?endswitch;?>
</html>

THIS DOESN'T WORK:

<html>
<?switch ($a):?>
[space]<?case 0: echo "zero"; break;?>
<?default: echo "one"; break;?>
<?endswitch;?>
</html>



Expected result:
----------------
"zero"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-21 16:37 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Read Zeev's response to the original bug report. 
 [2004-07-21 17:38 UTC] devis at witcom dot com
<? switch($var){ ?>
<? case "alpha":
  break;
}?>

should be equivalent to 

<? switch($var){ 
 print "\n"
 case "alpha":
  break;
}?>

so why does it work if this 

<? switch($var){ 
 print " "
 case "alpha":
  break;
}?>

does not work ?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 11 15:01:28 2024 UTC