Bug #62175 [Opn->Nab]: single quotes vs double quotes give different results with token_get_all

From: Date: Tue, 29 May 2012 08:53:16 +0000
Subject: Bug #62175 [Opn->Nab]: single quotes vs double quotes give different results with token_get_all
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-170893@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62175&edit=1

 ID:                 62175
 Updated by:         johannes@php.net
 Reported by:        iam4webwork at hotmail dot com
 Summary:            single quotes vs double quotes give different
                     results with token_get_all
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Scripting Engine problem
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 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




Previous Comments:
------------------------------------------------------------------------
[2012-05-29 00:54:29] anon at anon dot anon

You forgot to escape the $, so the variable got substituted into the string before tokens_get_all
even saw it. Should be:

$tokens = token_get_all("<?php \"{\$bar}\";");

------------------------------------------------------------------------
[2012-05-29 00:23:26] iam4webwork at hotmail dot com

Description:
------------
$tokens = token_get_all('<?php "{$bar}";');

vs.

$tokens = token_get_all("<?php \"{$bar}\";");

Test script:
---------------
$tokens = token_get_all('<?php "{$bar}";');
foreach ($tokens as $token) if (is_array($token)) print token_name($token[0]) ."\n";
echo '<P>';
$bar = 'bar'; // to avoid error notice
$tokens = token_get_all("<?php \"{$bar}\";");
foreach ($tokens as $token) if (is_array($token)) print token_name($token[0]) ."\n";

Expected result:
----------------
T_OPEN_TAG
T_CURLY_OPEN
T_VARIABLE

T_OPEN_TAG
T_CURLY_OPEN
T_VARIABLE

Actual result:
--------------
T_OPEN_TAG
T_CURLY_OPEN
T_VARIABLE


in the 2nd case got this instead:

T_OPEN_TAG
T_CONSTANT_ENCAPSED_STRING


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62175&edit=1


Thread (3 messages)

« previous php.bugs (#170893) next »