Re: from mysql in associative array [message #183974 is a reply to message #183972] |
Fri, 29 November 2013 23:56 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Fri, 29 Nov 2013 22:26:30 +0000, Ben Bacarisse wrote:
> Thomas 'PointedEars' Lahn <PointedEars(at)web(dot)de> writes:
>
>> Tony Mountifield wrote:
>>> I wrote:
>>>> if ($sh) {
>>
>> Insufficient, RTFM.
>
> Can you say why?
I'd guess tpel is postulating a resource with a non truthy value being
returned from mysql_query, although I also note that reading the manual
entry for mysql_query the section on return value does *_NOT_* contain
the standard warning about valid false return values.
'if ($sh) {}' appears to be fine according to the manual, which also
states that a resource is always truthy[1], unlike an int where 0 may be
a valid response that would evaluate as false, or a string where "" or
"0" could likewise be a valid return value which would evaluate to false.
The manual entry for array_search contains the following text in the
return value section:
"Warning
This function may return Boolean FALSE, but may also return a non-Boolean
value which evaluates to FALSE. Please read the section on Booleans for
more information. Use the === operator for testing the return value of
this function."
However the manual entry for mysql_query does not contain this warning.
Of course, tpel might have some other rationale and it's always possible
he's not just talking out of his arse again.
[1] http://php.net/manual/en/language.types.boolean.php
" When converting to boolean, the following values are considered FALSE:
the boolean FALSE itself
the integer 0 (zero)
the float 0.0 (zero)
the empty string, and the string "0"
an array with zero elements
an object with zero member variables (PHP 4 only)
the special type NULL (including unset variables)
SimpleXML objects created from empty tags
Every other value is considered TRUE (including any resource). "
--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
|
|
|