php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #44889 T_OPEN_TAG doesn't match <?php without any trailing characters
Submitted: 2008-05-02 07:18 UTC Modified: 2015-02-23 09:58 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mikec at resnet dot net dot nz Assigned: jpauli (profile)
Status: Closed Package: *General Issues
PHP Version: 5.3CVS-2008-05-02 (snap) OS: *
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: mikec at resnet dot net dot nz
New email:
PHP Version: OS:

 

 [2008-05-02 07:18 UTC] mikec at resnet dot net dot nz
Description:
------------
First noticed when including a file containing only "<?php", without a trailing new line character. I expected this would output nothing, but instead it outputted "<?php" to the browser.

This only occurs with 'short_open_tag' set to 'off', when set to 'on' including the same file outputs nothing, as expected.

The tokenizer expects a character after the long open tag, I suggest that this be extended to check for the end of the input too.


Reproduce code:
---------------
var_dump(ini_get('short_open_tag'));
print_r(token_get_all('<?php'));
print_r(token_get_all('<?'));

Expected result:
----------------
string(0) ""
Array
(
    [0] => Array
        (
            [0] => 368
            [1] => <?php
            [2] => 1
        )

)
Array
(
    [0] => Array
        (
            [0] => 311
            [1] => <?
            [2] => 1
        )

)

Actual result:
--------------
string(0) ""
Array
(
    [0] => Array
        (
            [0] => 311
            [1] => <?
            [2] => 1
        )

    [1] => Array
        (
            [0] => 311
            [1] => php
            [2] => 1
        )

)
Array
(
    [0] => Array
        (
            [0] => 311
            [1] => <?
            [2] => 1
        )

)

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-02 07:29 UTC] mikec at resnet dot net dot nz
First Seen On:
  PHP Version 5.2.5 on Fedora Core 6

Reproduced on (and actual/expected results from):
  PHP 5.3.0-dev (cli) (built: May  2 2008 00:17:56)
  Copyright (c) 1997-2008 The PHP Group
  Zend Engine v2.3.0, Copyright (c) 1998-2008 Zend Technologies

  From snaps: php5.3-win32-200805020430.zip
  Running on Windows Vista 32bit
 [2010-09-02 06:44 UTC] daniel at danielnorton dot com
The descriptions of the behavior is different from what I see. With 
'short_open_tag' set to 'On', I get this error:

PHP Parse error:  parse error in min.php on line 1

I get the same behavior when 'short_open_tag' is set to 'Off'.

PHP 5.3.0 (cli) (built: Jun 29 2009 21:25:23)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
 [2015-01-09 01:16 UTC] ajf@php.net
Can't reproduce for PHP 5.6:

$ php
<?php
var_dump(ini_get('short_open_tag'));
print_r(token_get_all('<?php'));
print_r(token_get_all('<?'));
string(0) ""
Array
(
    [0] => Array
        (
            [0] => 314
            [1] => <?php
            [2] => 1
        )

)
Array
(
    [0] => Array
        (
            [0] => 314
            [1] => <?
            [2] => 1
        )

)

oa-res-26-240:~ ajf$ php -v
PHP 5.6.3 (cli) (built: Nov 18 2014 15:15:01) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
 [2015-02-23 09:58 UTC] jpauli@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: jpauli
 [2015-02-23 09:58 UTC] jpauli@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

This can't be reproduced on latest 5.5 nor 5.6.
closing
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Aug 09 15:00:03 2025 UTC