Re: why use {} around vraiable?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

On Thu, Mar 20, 2008 at 12:22 PM, Lamp Lists <lamp.lists@xxxxxxxxx> 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.parsing.simple
and here
http://us.php.net/manual/en/language.types.string.php#language.types.string.parsing.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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux