Re: Re: Miserable escape string problem
| From: | tg-php at gryffyndevelopment dot com | Date: | Thu, 05 Oct 2006 16:12:33 +0000 |
| Subject: | Re: Re: Miserable escape string problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-242680@lists.php.net to get a copy of this message | ||
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.
= = = Original message = = =
Well Kae, if you reply 3 times let me also reply you once.
What you try to suggest is a workaround. A workaround should
not be needed for such a basic thing. Ever.
The point is, \ should escape only the , just like
it does when you escape a variable like this "\$var1"
In this case, \ only escapes the $.
Even then, why does it output the \?
Try this:
=========================================================
$var1 = 1;
$var2 = 2;
print("\$var1: $var2");
=========================================================
It will output: \1: 2
Why the \? Isn't it an escape character.
If you try to get me thinking that this is normal behaviour,
let's agree to disagree.
PS: I'd like to see an insider comment on this, eventually
explain the thought behind this implementation.
Kae Verens wrote:
> because $var1 is a valid syntactical construct?
>
> try this instead:
> ''.$var1.': '.$var2.''
>
> Kae
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.