| Quotes Inside Quotes Very interesting, Did you know this? |
Anyango

msg:4268315 | 6:46 am on Feb 17, 2011 (gmt 0) | Everyone knows that Single quotes will work inside double quotes and double quotes will work inside single quotes but do many people know this will work too ?
$test=array(); $test["title"]="Testing 123"; echo "Title is {$test["title"]}. See it works!";
Emphasis is not on the ability to use an array value inside quotation marks, but on the quotation marks themselves. Did you know this ?
|
coopster

msg:4268412 | 2:07 pm on Feb 17, 2011 (gmt 0) | Yes, I did, and use it quite often! Except my programming preference is to use single quotes around literal values in my array indexes ;) I have my IDE set up so that the vars stand out in different color text and this form of syntax works great, especially in HEREDOC. I even use class methods within the HEREDOC with this syntax. For example, lets say the $date variable is an instance of a class for handling date functions, like adding the english ordinal suffix "th" to the current day "17" to display as "17th":
require_once 'class/DateFunctions.php'; $date = new DateFunctions(); $month = date('M'); $day = date('j'); $output = <<<EOT <table> <tr> <td>Date:</td> <td>{$month} {$day}{$date->getEnglishOrdinalSuffix($day)}</td> </tr> </table> EOT; print $output; This and more can be found in the online PHP manual under Strings [php.net].
|
rocknbil

msg:4268598 | 7:29 pm on Feb 17, 2011 (gmt 0) | It's still nowhere as usable as Perl's qq//; :-) It's the one thing I really miss in PHP.
|
|
|