Quiz Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply

What is the value of $foo? (see code below)

Poll ended at Mon Jul 17, 2006 3:31 pm

10
8
67%
12
4
33%
 
Total votes: 12

User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Quiz Question

Post by Ollie Saunders »

No testing the code, now! That's cheating.

Code: Select all

$bar['5'] = 12;
$bar[5] = 10;

$foo = $bar['5'];
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

OK, I'll bite.

10.

PS And I didn't even cheat neither.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

yep its 10.

I thought it was a good feature that I didn't know about till today.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

It's talked about a little bit in the array section of the manual. In fact, I think a poster asked a question along these lines within the last few days.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

It's talked about a little bit in the array section of the manual. In fact
yep it is. which is why its amazing i'd never noticed it before.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I have found so many things in the manual 'by accident' that I hadn't known about, you'd be amazed. I am constantly learning new stuff.
Post Reply