Re: RFC: C-sharp style property get/set syntax for PHP
| From: | president at basnetworks dot net | Date: | Thu, 02 Dec 2010 14:18:04 +0000 |
| Subject: | Re: RFC: C-sharp style property get/set syntax for PHP | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-50818@lists.php.net to get a copy of this message | ||
Hi Lester,
>> Its a defacto standard. Of course there is nothing stopping PHP from
>> implementing properties that way, but by going against the standard set
>> by
>> the rest of the industry, it is very confusing for programmers coming
>> from
>> other languages to learn PHP. A good example is how "==" works
>> differently in PHP than in other languages. In PHP, "===" works like
>> "=="
>> does everywhere else. "(string)'0' == (int)0", for example is true in
>> PHP, but false in most other languages. I have had countless
>> conversations with PHP developers who claim the language is "broken",
>> because == does not work like they expect it to, after which I have to
>> explain === to them. This is because PHP goes against the defacto
>> standard. Maybe it would have been better if == and === had the
>> opposite
>> meaning, as to not squash the standard?
>
> You have got me there.
> = is assign
> == is equal value
> === is equal type and value
>
> At least on all the languages I've been using recently ... where is this a
> problem?
In any language that does not have === it is like this:
= is assign
== is equal type and value
That is where the confusion comes from. People do not expect "0" and 0 to
be equal, because they are different types.
- Dennis