Bug #52897 [Opn]: Strings variable parsing - complex syntax

From: Date: Tue, 21 Sep 2010 03:24:04 +0000
Subject: Bug #52897 [Opn]: Strings variable parsing - complex syntax
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-154521@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52897&edit=1

 ID:                 52897
 Updated by:         joey@php.net
 Reported by:        chealer at gmail dot com
 Summary:            Strings variable parsing - complex syntax
 Status:             Open
 Type:               Bug
 Package:            Unknown/Other Function
 PHP Version:        Irrelevant
 Block user comment: N

 New Comment:

patch #303636 documents the fact that surelynot() does not work


Previous Comments:
------------------------------------------------------------------------
[2010-09-21 04:56:06] chealer at gmail dot com

Description:
------------
Strings variables parsing, as documented on
http://ca2.php.net/manual/en/language.types.string.php#language.types.string.parsing
is partly broken, or incorrectly documented.
The documentation says:

In fact, any value in the namespace can be included in a string with
this syntax. Simply write the expression the same way as it would appear
outside the string, and then wrap it in { and }.

But this seems to only work with pre-computed values accessible through
variables (using the dollar sign). This works neither for return values
of functions in the namespace, nor for constants.

BTW, in the examples, there is an extra backslash for the method
example:
This is the value of the var named by the return value of
\$object->getName():

Test script:
---------------
<?php
namespace test;

$working = "works";
const MAYBENOT = "doesnt";
function surelynot() {
	return "neither";
}

$str = <<< DOC
A {$working} B {MAYBENOT} C {surelynot()} D
DOC;
echo $str;


Expected result:
----------------
A works B doesnt C neither D

Actual result:
--------------
A works B {MAYBENOT} C {surelynot()} D


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



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


Thread (4 messages)

« previous php.bugs (#154521) next »