Bluehost.com Web Hosting $6.95

Re: [PHP] why use {} around vraiable?

This is a discussion on Re: [PHP] why use {} around vraiable? within the PHP General forums, part of the PHP Programming Forums category; ----- Original Message ---- From: Nathan Nobbe <quickshiftin@gmail.com> To: Lamp Lists <lamp.lists@yahoo.com> Cc: ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-20-2008
Lamp Lists
 
Posts: n/a
Default Re: [PHP] why use {} around vraiable?

----- Original Message ----
From: Nathan Nobbe <quickshiftin@gmail.com>
To: Lamp Lists <lamp.lists@yahoo.com>
Cc: php-general@lists.php.net
Sent: Thursday, March 20, 2008 11:35:42 AM
Subject: Re: [php] why use {} around vraiable?

On Thu, Mar 20, 2008 at 12:22 PM, Lamp Lists <lamp.lists@yahoo.com> wrote:

> hi,
> I saw several times that some people use this
>
> $parameters = array(
> 'param1' => "{$_POST["param1"]}",
> 'param2' => "{$_POST["param2"]}"
> );
>
> or
>
> $query = mysql_query("SELECT * FROM table1 WHERE id='{$session_id}'");
>
> I would use:
>
> $parameters = array(
> 'param1' => $_POST["param1"],
> 'param2' => $_POST["param2"]
> );
>
> and
>
> $query = mysql_query("SELECT * FROM table1 WHERE id=' ".$session_id." '
> ");
>
>
> does it really matter? is there really difference or these are just two
> "styles"?



the short answer is yes.
i think you can find a sufficient explanation here,
http://us.php.net/manual/en/language.types.string.php#language.types.string.pa rsing.simple
and here
http://us.php.net/manual/en/language.types.string.php#language.types.string.pa rsing.complex

-nathan



ok. I got it.
actually, my question was about: these two examples

$fruits = array('strawberry' => 'red', 'banana' => 'yellow');
echo "A banana is {$fruits['banana']}.";
echo "A banana is " . $fruits['banana'] . ".";

are the same.

Though, learned few more other things too :D

Thanks guys.

-ll


__________________________________________________ __________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:58 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0