#25725 [Ver->Bgs]: highlight_string doesn't parse strings containing \ properly
| From: | iliaa@php.net | Date: | Fri, 03 Oct 2003 00:56:58 +0000 |
| Subject: | #25725 [Ver->Bgs]: highlight_string doesn't parse strings containing \ properly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-48472@lists.php.net to get a copy of this message | ||
ID: 25725
Updated by: iliaa@php.net
Reported By: kjartan at zind dot net
-Status: Verified
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: *
PHP Version: 4CVS, 5CVS
New Comment:
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
The warning you are seeing is a lexical parser warning, it cannot be
avoided simply because it is the same parser as the one parsing normal
PHP source. If PHP were to execute the file it too would strip/ignore
the \ character.
Previous Comments:
------------------------------------------------------------------------
[2003-10-02 17:03:45] kjartan at zind dot net
Doing @highlight_string seems to work to, but it strips the \. Might
not fixing, but it still seems like a bug.
------------------------------------------------------------------------
[2003-10-02 16:51:07] moriyoshi@php.net
If you just want to suppress warnings, error_reporting(0) might help
you. I'm not sure if this needs to be fixed anyhow though...
------------------------------------------------------------------------
[2003-10-02 07:17:27] kjartan at zind dot net
Description:
------------
Given a string that contains this PHP code:
<?php
$a = 2;
\;
$b = 3;
?>
Then highlight_string() generates this:
<?php
$a = 2;
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/home/kjartan/scripts/highlight_string on line 9
;
$b = 3;
?>
Granted its not valid PHP, but should hightlight_string() function as a
PHP validation system? Not that it does a good job at it as this gets
colored just fine:
<?php
$a = 2
$b = 3
$c = 5
?>
What gives?
Reproduce code:
---------------
<?php
$string = '<?php
$a = 2;
\
$c = 5;
?>';
highlight_string($string);
Expected result:
----------------
I expect it to just leave the \ alone and not cause warnings.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25725&edit=1