RE: [PHP] is <?= good?
| From: | Daevid Vincent | Date: | Mon, 14 Jun 2010 18:51:59 +0000 |
| Subject: | RE: [PHP] is <?= good? | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-306139@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Paul M Foster [mailto:paulf@quillandmouse.com]
> Sent: Saturday, June 12, 2010 10:40 PM
>
> this in PHP. I can convert from '.' to '+' (as in most
> languages) in my
> mind, but embedding variables in strings was a harder habit
> to break. My
> opinion is that the dot operator used this way was a mistake for
> PHP. Not using the dot operator to mean "concatenate" would mean we
> could use it to replace the accursed '->' for class/method selection.
> And the plus operator is obviously a more natural fit for string
> concatenation.
>
> And yes, if you're going to use the dot operator, surround it with
> spaces for readability.
Ironically, I believe that in the old days of PHP/FI the "+" was used
instead of "." -- to their defense, OOP wasn't even around then and so no
precedent had been set for the "." and I think they wanted to avoid
confusion with actual addition. I just remember having to go through and
re-work a bunch of code that broke b/c of this change.
But yes, I agree with you there. + should have stayed as the concat AND
addition, just like in JavaScript and other languages, and "." should have
been used instead of "->"
All of this I think could have been done AND maintain backwards
compatability with the use of some php.ini directives. Alternatively, I bet
some fancy regex scripts could also have been written that would migrate
"old" code to "new" code styles (I think the python guys did this for
"print")
*sigh*. It is what it is now. Ain't no going back from here. Like it or
lump it as they say.