Re: Re: Miserable escape string problem

From: Date: Thu, 05 Oct 2006 16:50:19 +0000
Subject: Re: Re: Miserable escape string problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-242687@lists.php.net to get a copy of this message
Either your mail client is broken, or you're misquoting him on purpose:
    Using this string:
    "{$var1: $var2}"
    ....of course it doesn't work as some might expect.
Thanks Chris, I already emailed him on private 'cause I didn't
want to clutter the list unneeded.
To address the original question, a backslash does not escape the brace. Are you wanting the variables to be evaluated? Here's an example that demonstrates both:
It occurs to me I wasn't clear enough, although one could have figure it out. By using this: =============================== $var1 = 11; $var2 = 22; outputstringfunction("{$var1: $var2}"); //hypothetical code =============================== I'd like to have the output as "{11: 22}". By using "{{$var1}: {$var2}}" it works just fine, but this is a mess, I can't live with. What I am using now is "{ $var1: $var2}", better. I guess what I am asking for is more or less uninteresting to most of the PHP developers(many are just coders, really... for the difference search the net) that eat up whatever offered, so I might just rest my case. So, yes, there is no escaping for { in PHP and that would be it.
<?php $foo = '123'; $bar = '456'; echo "{{$foo}: {$bar}}"; echo '{$foo: $bar}'; ?> Hope that helps. Chris


« previous php.general (#242687) next »