php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36037 heredoc adds extra line number
Submitted: 2006-01-16 21:58 UTC Modified: 2006-01-17 10:42 UTC
From: nospam at 1111-internet dot com Assigned: dmitry
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS, 4CVS (2006-01-17) (cvs) OS: *
Private report: No CVE-ID:
 [2006-01-16 21:58 UTC] nospam at 1111-internet dot com
Description:
------------
Heredoc syntax adds one extra line number and thus skews all subsequent script line numbers. Example uses PHP CLI, but also affects PHP as Apache module.

Reproduce code:
---------------
<?php
echo __LINE__, "\n";
$x=<<<XXX
123
XXX;
echo __LINE__, "\n";
?>


Expected result:
----------------
2
6


Actual result:
--------------
2
7


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-16 22:10 UTC] tony2001@php.net
Dmitry, check out the patch, plz:
Index: Zend/zend_language_scanner.l
===================================================================
RCS file: /repository/ZendEngine2/zend_language_scanner.l,v
retrieving revision 1.131.2.9
diff -u -p -d -r1.131.2.9 zend_language_scanner.l
--- Zend/zend_language_scanner.l        4 Jan 2006 23:53:04 -0000       1.131.2.9
+++ Zend/zend_language_scanner.l        16 Jan 2006 21:09:17 -0000
@@ -1706,7 +1706,6 @@ NEWLINE ("\r"|"\n"|"\r\n")

 <ST_IN_SCRIPTING>"<<<"{TABS_AND_SPACES}{LABEL}{NEWLINE} {
        char *s;
-       CG(zend_lineno)++;
        CG(heredoc_len) = yyleng-3-1-(yytext[yyleng-2]=='\r'?1:0);
        s = yytext+3;
        while ((*s == ' ') || (*s == '\t')) {
 [2006-01-17 10:42 UTC] dmitry@php.net
Fixed in CVS HEAD, PHP_5_1 and PHP_4_4.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 23:01:58 2014 UTC