Req #44889 [Com]: T_OPEN_TAG doesn't match <?php without any trailing characters

From: Date: Fri, 09 Jan 2015 01:16:33 +0000
Subject: Req #44889 [Com]: T_OPEN_TAG doesn't match <?php without any trailing characters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189814@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=44889&edit=1 ID: 44889 Comment by: ajf@php.net Reported by: mikec at resnet dot net dot nz Summary: T_OPEN_TAG doesn't match <?php without any trailing characters Status: Open Type: Feature/Change Request Package: Feature/Change Request Operating System: * PHP Version: 5.3CVS-2008-05-02 (snap) Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2010-09-02 06:44:50] 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 ------------------------------------------------------------------------ [2008-05-02 07:29:57] 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 ------------------------------------------------------------------------ [2008-05-02 07:18:30] 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 ) ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=44889&edit=1

« previous php.bugs (#189814) next »