
Originally Posted by
arkinstall
PHP Code:
<?php
String $var = "hello";
Int $num = Integer.parseInt($_GET['number']);
Var $something; //can equal anything.
?>
That looks way too much like Java. PHP is dynamically typed for a reason, and I've come to appreciate certain aspects of it's dynamically-typed nature. If anything, PHP should go more towards a full OO language by automatically creating the necessary objects by declared value type implicitly, like Ruby and Python do - something like this:
PHP Code:
<?php
$var = "hello"; // automatic string object
$num = 1234; // automatic integer object
$regex = "/(.*)/i"; // automatic regex object
?>
And then all the PHP functions would have to be modified to accept the new base object type as well, like:
PHP Code:
<?php
$sub = substr($var, 0, 2); // equals "he"
// Also new syntax is provided for the new object types
$sub = $var->substr(0, 2); // equals "he"
?>
So at least to me, that would be the perfect way to take PHP to the OO-level for those who want it, and keep it looking like flat dynamic variables for those who don't.
Bookmarks