You are here: Re: newbie question: using $_POST inside of array parameters? « PHP Programming Language « IT news, forums, messages
Re: newbie question: using $_POST inside of array parameters?

Posted by Kimmo Laine on 08/30/06 12:39

"Alvaro G. Vicario" <webmaster@NOSPAMdemogracia.com> wrote in message
news:rj72wmibg02j.622tzkodwvj7.dlg@40tude.net...
> *** kurrent@gmail.com escribiσ/wrote (29 Aug 2006 14:24:02 -0700):
>> <select name=b size=1>
>> <option value=1>number1</option>
>> <option value=2>number2</option>
>> <option value=0>number3</option>
>> </select>
>
>
>>>From my understanding, I see that $_POST[b] would successfully retrive
>> the value of the $b variable. So i've tried many variants on the syntax
>> but no luck (e.g. "$a[$_POST[b]]) etc...
>
> I'm unsure of what you're trying to accomplish, but you must learn the
> syntax of the different types of identifiers:
>
> $foo -> variable
> foo() -> function or class
> 'foo' -> string
> "foo" -> string with variables
> foo -> constant
>
> So $_POST[b] won't make any sense unless you previously define a constant
> called b:
>
> define('b', 'whatever');


That's not entirely true. if there is no constant named foo, it is
interpreted as "bare string", an unquoted string. Ie. it is treated just
like a string, but a warnign message is generated. So basicly $a[$_POST[b]]
would work. This is a bad practise and should be avoided always to
distinguish the difference between a constant and a string. Bare strings is
a terrible terrible feature implemented only for backwards compatibility, I
can't imagine anyone seriously using it. But it's there, and it works. A
programmer should be aware of the peculiar features of the language even
thou they aren't used.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net || Gedoon-S @ IRCnet || rot13(xvzzb@bhgbyrzcv.arg)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация