Re: Re: Miserable escape string problem

From: Date: Thu, 05 Oct 2006 17:37:59 +0000
Subject: Re: Re: Miserable escape string problem
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-242695@lists.php.net to get a copy of this message
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/

« previous php.general (#242695) next »