[FX.php List] Stumbled on something I hadn't realized...

Anders Monsen andersm at alamark.com
Thu Nov 13 14:06:29 MST 2008


Thanks for the tip, Andy.

I have seen that format but never internalized how useful it could be  
with as a method to avoid escaping the double quotes.

Anders

On Nov 13, 2008, at 2:03 PM, Andy Gaunt wrote:

> Where you deal with an array such as $_POST, $_GET, $_SESSION or one  
> you create you can wrap those in curly quotes inside your doubles to  
> avoid extra concatenation.
>
> eg:
>
> "The first name is {$_POST['nameFirst'] } and the last name etc";
>
> Also, if you are typing a lot of HTML code within the quotes with  
> variables included, you may want to look into HEREDOC as then double  
> quotes do not need to be escaped for your HTML or switched out for  
> single quotes.
>
> $code = <<<EOD
> <p class="primary">Hello $firstName</p>
> <p>You posted {$_POST['details']} to our form</p>
> <p>Your email is $email</p>
> EOD;
>
> echo $code;
>
> Cheers
>
> Andy Gaunt
> T: 321-206-3658
> andy at fmpug.com
> http://www.fmpug.com
>
> FMPug.com: A Developer's best Friend!
>
> FindFileMakerDevelopers.com -
> The #1 listings engine for FileMaker Professionals
>
>
>
>
>
>
> On Nov 13, 2008, at 2:28 PM, Bob Patin wrote:
>
>> You're right; I just tried it to see what would happened, and got a  
>> parse error... (with a $_GET).
>>
>> BP
>>
>>
>> On Nov 13, 2008, at 1:25 PM, Anders Monsen wrote:
>>
>>> If you pull in something like $_POST['nameFirst'] you may still  
>>> need to concatenate:
>>>
>>> "The first name is " . $_POST['nameFirst'] . " and the last name  
>>> etc";
>>>
>>> Anders
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>



More information about the FX.php_List mailing list