|
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)
[Back to original message]
|