Let's look at your original message:
--------------------
Using this string:
"$var1: $var2"
....of course it doesn't work as some might expect.
--------------------

It works exactly as expected.  Within double-quotes, things like variables get 
evaluated.  In this case $var1 and $var2 will be replaced by their values.  
That's what's "expected".

--------------------
But why in the name of [whatever, too many to list] doesn't this one 
below work?
"\$var1: $var2"

If \ is an escape character why does it also appear in the string output?
Why does the above \ escape $var1 and not only the ?
--------------------

In the test I did, it behaves exactly as it's expected to behave.  "\" escapes 
the next character.  Or in the case of some characters, there may be more than 
one after the \ that get interpreted.  For example "\x41" is hexdecimal value 
41.

The \$var1 above is indicating you want to display a "$" literally and not 
interpret it despite being contained within double-quotes.  The "var1" part, 
not having a "$" on the front of it, doesn't get interpretted as anything and 
is output literally as "var1".

Maybe rephrasing the question would help because reading your original message 
doesn't tell me anything except that there's a communication problem.

Unless "\$var1: $var2" does NOT output "$var1: <somevalue>", then everything is 
functioning as designed and expected.

-TG


= = = Original message = = =

Sorry tg, you missed the whole point. Read again.
> The escaping works fine for me.. using the code:
>
> $var1 = 1;
> $var2 = 3;
>
> echo "\$var1: $var2";
> print "\$var1: $var2";
> print ("\$var1: $var2");
>
> All output:
>
> $var1: 3
>
> as expected.
>
> Is there a way to re-define the escape character or something?  I can't think 
> of why that wouldn't escape the $ properly
>   


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to