php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #36729 Alternative syntax for switch() rejects whitespace
Submitted: 2006-03-13 23:44 UTC Modified: 2006-03-14 15:17 UTC
From: loikiolki at yahoo dot ca Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: * OS: *
Private report: No CVE-ID: None
 [2006-03-13 23:44 UTC] loikiolki at yahoo dot ca
Description:
------------
There is a bug regarding whitespace surrounding opening/closing php tags when using the alternative syntax for switch() statements. If you try to insert a tab or spaces before the opening php tag for the first case statement (<TAB><? case 'one': ?>), php dies with "PHP Parse error:  syntax error, unexpected T_INLINE_HTML, expecting T_ENDSWITCH or T_CASE or T_DEFAULT". I realize that the only valid text between the 'switch' and first 'case' statement must be a 'case' or 'default' label, but whitespace should be an exception.

Reproduce code:
---------------
// Works if whitespace before "<? case 'one:': ?>" is removed

$var = 'one';
<? switch($var): ?>
    <? case 'one': ?>
        <p>switch found one</p>
	<? break; ?>
    <? case 'two': ?>
        <p>switch found two</p>
        <break; ?>
    <? default: ?>
        <p>switch found something else</p>
<? endswitch; ?>

Expected result:
----------------
<p>switch found one</p>

Actual result:
--------------
PHP Parse error:  syntax error, unexpected T_INLINE_HTML, expecting T_ENDSWITCH or T_CASE or T_DEFAULT in __FILE__ on line xxx

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-13 23:52 UTC] helly@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

.
 [2006-03-14 05:48 UTC] loikiolki at yahoo dot ca
How is this not a bug? Whitespace should be acceptable between the closing php tag and the opening php tag. Telling me to "double-check the documentation" and giving the manual's index does nothing to point me in the right direction. Could you please explain a little better or give me the link to the documentation page that says whitespace is not permittable.
 [2006-03-14 15:17 UTC] mgf@php.net
This is a duplicate of bug #25667, and the explanation there applies.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC