Posted by Colin McKinnon on 02/05/06 23:54
Justin Koivisto wrote:
> Wayne wrote:
>> On 3 Feb 2006 09:03:34 -0800, "comp.lang.php"
>> <phillip.s.powell@gmail.com> wrote:
>>
>>> [PHP]
>>> print_r(is_int('1')); // PRINTS NOTHING
>>> print_r(strlen((int)1)); // PRINTS '1'
>>> [/PHP]
>>>
>>> Now I understand that in PHP, everything scalar is a string
>>
>> *bzzt* wrong. This is where you are getting lost.
>>
>> Everything has a type -- so integers are integers and strings are
>> strings and booleans are booleans. However, PHP will automatically
>> cast scalars to different types as appropriate for a function or
>> operator.
>
> That phrasing is a little confusing...
> integer, float, string and boolean are *all* scalar types. (The only 4
> scalar types supported by PHP.)
>
> Supported types that are not scalar are:
> * the 2 compound types array and object
> * the 2 special types NULL and resource.
>
*bzzt* wrong
PHP references are scalar - but in most instances dereferencing is
transparent and higher precedence than casting.
I believe that resources and NULL are also scalars but not castable.
C.
[Back to original message]
|