php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33081 T_OPEN_TAG eats whitespace
Submitted: 2005-05-20 15:53 UTC Modified: 2005-05-20 16:58 UTC
From: jaa at interflow dot dk Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.4 OS: FreeBSD
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: jaa at interflow dot dk
New email:
PHP Version: OS:

 

 [2005-05-20 15:53 UTC] jaa at interflow dot dk
Description:
------------
The PHP tokenizer includes the first whitespace character after the opening php tag as a part of the opening tag. That is, the following code with one whitespace in between will be tokenized into two tokens, a start tag and a closing tag:
<?php ?>

While with two whitespaces in between will be tokenized into three tokens, an opening tag including one space character, a whitespace token with one space character and a closing tag:
<?php  ?>

I hope the whitespace doesn't get lost when I submit this ;-)

Reproduce code:
---------------
<?php
$source = "<?php ?>";
$tokens = token_get_all($source);
if($tokens[1][0] == T_WHITESPACE) {
  print "Whitespace found\n";
} else {
  print "Whitespace not found\n";
}
?>


Expected result:
----------------
Whitespace found

Actual result:
--------------
Whitespace not found

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-20 16:59 UTC] derick@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


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 22:00:01 2026 UTC