|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
)
)
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 16:00:01 2025 UTC |
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