You are here: Portability, Compatibility and short tags « PHP « IT news, forums, messages
Portability, Compatibility and short tags

Posted by Jochem Maas on 11/16/05 14:20

nevermind the short tags issue! ;-)

- there is a chance that autocasting [of function arguments] is going to change to
be stricter and no longer work the same as explicit casting so that the following 2
echos statement would no longer work the same (the first would fail).

$str = "This is a test";
$cnt = "3abc";

echo substr($str, 0, $cnt); // would fail (3rd arg not numeric)
echo substr($str, 0, (int)$cnt); // works fine

my feeling is that the inconsistency will make the language less attractive, if php is
autocasting then I expect it to cast in the same way internally as when I
ask for it explicitly - if it doesn't I have to memorize the differences, which
is another reason to start looking into other languages (ruby anyone?) and certainly
the kind of thing to really confuse beginners.

anyone else want to speak up against the proposed results of such a change?
(please dig into the internals mailing list to read more on the subject)

the arugment (AFAICT) behind the stricter casting is the ever more popular
"helps developers catch stupid/hard-to-find bugs before they cause a problem"
argument, which to me is becoming a bit long in the tooth. At some stage there
will be so many hoops you have to jump through (and know that the hoops exist in
the first place) before you can get anything done that the net result is:

YES, these purist/strict/help-the-dev-catch-difficult-php-bugs-before-they-bite-him-
in-the-ass have helped reduce the ammount of bad php code begin written .... because
everyone is writing their apps in another language.

another example of this mentality is the fact that array_merge() only excepts array()s
where are in the past other type of vars were automatically cast to array.

ok that became a bit of a rant - it's just I really like php and I rather want it
to stay likable :-)

rgds,
Jochem

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация