|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26629 Inconsistent handle of \n in highlight_string and highlight_file
Submitted: 2003-12-15 05:57 UTC Modified: 2003-12-19 06:39 UTC
From: Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.4 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2003-12-15 05:57 UTC]
highlight.keyword isn't used in strings without variables for \n and similar. It is used in strings with variables (e.g. "$a\n").

(The problem is in file /ZendEngine2/zend_highlight.c.)

Reproduce code:
highlight_string('<?php echo "a\n"; ?>');

Expected result:
<code><font color="#000000">
<font color="#0000BB">&lt;?php </font><font color="#007700">echo </font><font color="#DD0000">"a</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">; </font><font color="#0000BB">?&gt;</font>

Actual result:
<code><font color="#000000">
<font color="#0000BB">&lt;?php </font><font color="#007700">echo </font><font color="#DD0000">"a\n"</font><font color="#007700">; </font><font color="#0000BB">?&gt;</font>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-15 09:09 UTC]
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.

And is this with PHP 5 or 4 ??? You're referring to ZendEngine 2 but the version in this report is 4.3.3 ????

(I would expect that people who have address should know HOW to report bugs..)

 [2003-12-16 12:08 UTC]
Sorry for mismatch. The bug report is for PHP 4. I looked for highlighting code and I found it in /ZendEngine2 but I didn't realized that this code is for PHP 5 only. I don't know where this part of code for PHP 4 is. Just ignore the sentence in bracket, the provided version information is correct.
 [2003-12-16 12:22 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

This is how it supposed to work, "a\n" is 1 string.
 [2003-12-16 17:01 UTC]
I don't know what "1 string" is. Is "$a\n" also "1 string"? If it is, there should not be \n highlighted in it.

The problem is that in "$a\n" is \n highlighted and in "a\n" isn't. I believe that it should be consistent.
 [2003-12-16 17:11 UTC]
You're wrong. The current behavior is correct.
 [2003-12-17 03:51 UTC]
Tell me a reason why \n should be highlighted as keyword in "$a\n" and in "a\n" not.
 [2003-12-17 04:31 UTC]
Because the lexer in PHP handles those cases different.

"$a\n" = quote + variable + newline character + quote

"a\n"  = string

Try this script:
    highlight_string('<?php "a\n"; ?>');
    var_dump(token_get_all('<?php "a\n"; ?>'));
    highlight_string('<?php "$a\n"; ?>');
    var_dump(token_get_all('<?php "$a\n"; ?>'));

(and leave this bug bogus)
 [2003-12-19 06:15 UTC]
So the newline character should be highlighted as a string and not as a keyword.

If you will not fix this, change the state to Wont fix and not to Bogus.
 [2003-12-19 06:39 UTC]
The current behavior is CORRECT, so your report is BOGUS. highlight_* uses the lexical analyer to highlight and this is the perfectly good behavior as I told you atleast 5 times now. Please keep the status to bogus.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 22 06:01:34 2024 UTC