Re: $request problem
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: $request problem

From: ColdShine <coldshine_nounderscores_@hotmail.com>
Date: Sat Mar 11 2006 - 15:28:49 CET

Jerry Stuckle in news:WvadnQQMO-tzxI_ZRVn-gw@comcast.com wrote:

> Norman Peelman wrote:
>
>> echo "<p>Search words: $_REQUEST[input]";
>>
>> is (one of) the correct ways. Single quotes aren't needed/don't work when
>> the variable is enclosed in double quotes. Unless you enclose the
>> variable in curly braces:
>>
>> echo "<p>Search words: {$_REQUEST['input']}";
>>
>> will work properly too...
>
> Yes, if you turn on all errors you will get an E_NOTICE because the
> string is not quoted.

No E_NOTICE at all.

http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

There's no clear example stating this, but:

echo "$array[key]";

Is EXACTLY the same as:

echo "{$array['key']}";

With no notices being generated (I know since I always debug using E_ALL).
It's probably faster too, since I guess { "activates" a more complex parser.

Of course, that's the same as:

echo $array['key'];

-- 
ColdShine
"Experience is a hard teacher: she gives the test first, the lesson
  afterwards." - Vernon Sanders law 
Received on Mon May 1 02:31:15 2006