[ParrotHeadPoster] - Re: [PHP] escaping quotes
| From: | Jochem Maas | Date: | Thu, 27 Jan 2005 13:00:04 +0000 |
| Subject: | [ParrotHeadPoster] - Re: [PHP] escaping quotes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-207473@lists.php.net to get a copy of this message | ||
I had a parrot idea whilst writing this.. (see bottom)
Giles wrote:
Hi Guys Really simple question. How do I change the following: print("value='" . $attributes["messageSubject"] . "'"); to have double quotes around the subject field instead. i.e.: print("value="" . $attributes["messageSubject"] . """);you have to escape the doublequotes in question - this is done with a backslash: print("value=\"" . $attributes["messageSubject"] . "\""); or like this if you find it more readable (avoids the backslashes): printf('value="%s"', $attributes["messageSubject"]); actually you can do loads of funky things with printf() and its brother sprintf() etc - check out the manual for all the formating codes (e.g. '%s') that are available lastly, learn what string interpolation is and why it is technically neater to only use doublequotes to delimit your php strings when you want/require string interpolation to happen. --- ParrotTalk: I think that this topic of string interpolation/quotes deserves 'parrot' attention.... which made me think that maybe the parrot could parse for markers (that if added to an email by an autorized poster) would mark the post/thread as suitable material for 'training' the 'parrot'
thanks Giles Roadnight http://giles.roadnight.name