#28148 [Opn->Ver]: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARI
| From: | pollita@php.net | Date: | Sun, 25 Apr 2004 20:12:23 +0000 |
| Subject: | #28148 [Opn->Ver]: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARI | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-58746@lists.php.net to get a copy of this message | ||
ID: 28148
Updated by: pollita@php.net
Reported By: ca50015 at yahoo dot com
-Status: Open
+Status: Verified
Bug Type: Compile Failure
Operating System: windows 98 se
PHP Version: 5.0.0RC1
New Comment:
It's seeing $tagname[^\\>] as an array element (with an index of ^\>
which is, of course, invalid in an encapsed string context.
Not sure if this falls into "buggy" or "expected" beahvior as it's a
little gray...
Previous Comments:
------------------------------------------------------------------------
[2004-04-25 21:59:22] ca50015 at yahoo dot com
Description:
------------
Got parse error when double-quoted string contains variable.
[Code]
$pattern = "/\<$tagName[^\>]*\>/i";
[/Code]
[Error message]
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in php5bug.php on line
6
[/Error message]
I'm using php5.0.0rc1 in windows 98 from command line
the command is: "php -f php5bug.php"
the same I got while test with php5.0.0RC2
Reproduce code:
---------------
<?php
$text = "<script></script>";
$tagName = 'script';
//These won't work
$pattern = "/\<$tagName[^\>]*\>/i"; //backslash not escaped
$pattern = "/\\<$tagName[^\\>]*\\>/i"; // backslash escaped
//These work
$pattern = "/\<" . $tagName . "[^\>]*\>/i"; //backslash not escaped
$pattern = "/\\<" . $tagName . "[^\\>]*\\>/i"; // backslash escaped
?>
Expected result:
----------------
variables in double-quoted string could be altered
Actual result:
--------------
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\home\php5bug.php
on line 6
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28148&edit=1