Edit Global Variable?
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
but doesn't that sort of conflict with php array best practices?
My understanding is this: as long as you enclose your attribute fields in double quotes, using single quotes is fine. How else would you distinguish between an array key string and a constant?
http://ca3.php.net/manual/en/language.t ... rray.donts
On a less-related-note: How's that new job going, btw? You've been quiet lately
My understanding is this: as long as you enclose your attribute fields in double quotes, using single quotes is fine. How else would you distinguish between an array key string and a constant?
http://ca3.php.net/manual/en/language.t ... rray.donts
On a less-related-note: How's that new job going, btw? You've been quiet lately
I think that if you are using arrays in the name of XHTML fields, then the PHP rules don't necessarily apply. I think that if you had a constant defined, then used it as a key name in an XHTML field without quotes, the key would be created as a string (not the constant) due to the way PHP parses out the POST array. Same way as using <input name="thingy[somefunction()]"> would not call a function when the form was posted.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
yes that is precisely why $array[index] is such bad practice in PHP but you don't have constants in HTML do you. I haven't tested using quotes but I can be certain that they aren't required. My initial concern was that you would have to do this to get access to such post vars:How else would you distinguish between an array key string and a constant?
Code: Select all
<?php
echo $_POST['a']["'foo'"];
?>
<input type="text" name="a['foo']" />Well yes that is what I expected. Things still haven't settled down completely because the guy supposed to be configuring my production and development servers disappeared and now I need to find someone else. I've only had a development server and desktop machine in the last 3 days before that I've been working on my laptop. Actually having a desktop machine is much nicer (got my dual monitorsOn a less-related-note: How's that new job going, btw? You've been quiet lately
Hopefully I'll be around a bit more in a month's time or so when I'll actually be able to get stuck into some code.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact: