Re: Re: Miserable escape string problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Google Kreme wrote:
> So what is "{{$var1} : {$var2}}"

Within a quoted string, you can surround variable names with braces for
clarity. This is especially helpful for situations like this, where the
rest of the string interferes with syntax.

A more common example is when a variable name is immediately followed by
an alphabetic character:

<?php

$animal = 'cat';
$string = "I like $animals."

?>

When you try this, PHP thinks $animals is the name of the variable. If
you want to be clear that the name of the variable is $animal, you can
use braces:

$string = "I like {$animal}s.";

So, I don't consider this a workaround. It's clean, intuitive syntax for
exactly these types of scenarios.

Hope that helps.

Chris

-- 
Chris Shiflett
http://shiflett.org/

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux