>> $data = ‘12345′
>> isset($data['foo']) ? ‘beature’ : ‘not set’
I am just hacking away and just shrug. My AJAX request returns the following POST data data=[Object object]. Well, dojo obviously doesn’t resolve nested objects, so I get the ugly object string there. Ok, no problem.
But the interesting part here is that my PHP code behind expects an array and since I hadn’t implemented a type check the isset($data['foo']) returns true. What PHP does here (thanks to Alex Haslberger for the help figuring it out) is, it converts ‘foo’ into a 0 and uses the string $data to check if it has a character set at position 0. Which is true, of course.
I understand (don’t agree) that in PHP 1+’[’ returns 1, but the case above reveals that it might not be a good idea. Currently the type check has to be done by hand, which would be is_array() in my case, but is that really the right way?
I don’t feel like stressing my brain much more with it now, I am just too curious about our (Germany) quarter final game against Argentina … “don’t cry for me Argentina”