Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7523169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:43:06+00:00 2026-05-30T02:43:06+00:00

The following code: <?php//comment error_reporting(0); results (at least in 5.2.11) in: Parse error: syntax

  • 0

The following code:

<?php//comment
error_reporting(0);

results (at least in 5.2.11) in:

Parse error: syntax error, unexpected T_STRING

… which I find quite bizarre.

Whether or not <?php//comment should be allowed verbatim, I propose that there can be no doubt as to the bugginess of the contents of the parse error.

That’s because there is no T_STRING in sight (though I do understand that productions may form other productions to imbue precedence, e.g. additive-expressions encapsulating multiplication operations, and the like).

Can anyone with an understanding of the PHP grammar explain how this has come about?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:43:07+00:00Added an answer on May 30, 2026 at 2:43 am

    See the following snippet which looks for the <?php opening tag. Note the requirement of a trailing space, horizontal tab or new line.

    <INITIAL>"<?php"([ \t]|{NEWLINE}) {
        <snip>
        return T_OPEN_TAG;
    }
    

    (Source: zend_language_scanner.l from PHP 5.3.10)

    This means that PHP doesn’t see your code as a normal (long) open tag, but rather as having a short open tag.

    <INITIAL>"<?" {
        if (CG(short_tags)) {
            <snip>
            return T_OPEN_TAG;
        } else {
            goto inline_char_handler;
        }
    }
    

    (Source: zend_language_scanner.l from PHP 5.3.10

    The short tag does not require the trailing whitespace.

    So, the different parts of your code that PHP sees are <?, php, //comment, error_reporting…. The php is taken to be a constant (which doesn’t exist, see below). Then there is a comment, which is fine. However the next step is to call the error_reporting() function. This is not something that is allowed to happen at this point and it is now that PHP bails out, complaining that the identifier (the T_STRING) error_reporting was not expected.

    To demonstrate this, lets try some code that does work (meaning: PHP code is executed successfully) with short_open_tag enabled, but won’t with short_open_tag disabled.

    <?php//comment
    ;
    

    With error_reporting high enough to show notices, you’ll be able to see what goes wrong as the output is something like:

    Notice: Use of undefined constant php – assumed ‘php’ in example.php on line 2

    With short_open_tag turned off, the output will be the code in plain text since PHP does not try to execute it.

    Finally, a little reminder of the description about T_STRING in the List of Parser Tokens which says that T_STRING is for (don’t ask me why it’s not T_IDENTIFIER, T_BAREWORD or something less confusing):

    identifiers, e.g. strings, object oriented keywords like parent and self, functions, classes and more are matched.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've the following code in PHP which works fine (returns more or less 10
I have the following php code, which has been snipped for brevity. I am
I have the following PHP code which works out the possible combinations from a
I am using following PHP code for trigger creation but always get error, please
Since when did: //echo [$sql][$result][$rows][$e]<BR>; cause an error? The code following this comment gets
i have written the following code but it is giving parse error . here
The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128.
I have following PHP code $val=<div id=user.$row['cid']. userid=.$row['cid']. class=innertxt><img src=images/images.jpg width=50 height=50><strong>.$uname.</strong><ul> <li>Email: .$row['cemail'].</li>
I am running following PHP code to interact with a MS Access database. $odbc_con
I am using following PHP code to connect to MS Access database: $odb_conn =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.