home forums resources search newsjoinmembers: 6955
Sections PHP Flash Java Ruby Windows Linux
php's picture

php | Sun, 2008-08-24 20:00  tags: , , ,

Drupal is built on the PHP call_user_func() construct. The function has gotten a face lift in PHP 5.2.3 and will be getting further inhanced in PHP 5.3. But will Drupal and other similar applications be able to take advantage of the new power of PHP 5.3 or even PHP 6?

In the fireOrb fork of Drupal we are taking the core code and making use of PHP 5 to it's fullest. This means having to use OOP style architecture and coding to gain the advantages given by use of PHP 5.2+ and soon PHP 5.3. Call_user_func() changes are shown here but there may come more before the beta release of PHP 5.3 and PHP 6.

<?php

class myclass {
    static function 
say_hello($arg_1 NULL,$arg_2 NULL){
        echo 
"Hello! myfriend\n" $arg_1;
    }
}
function 
say_hello($arg_1 NULL,$arg_2 NULL){
        echo 
"Hello you!\n" $arg_1;
}
$classname "myclass";
$func 'say_hello';
call_user_func($func);
call_user_func(array($classname'say_hello'));//Done in FireOrb - legacy for =<5.2.3 required use of an array
call_user_func($classname .'::'.$func'para','meter'); // As of 5.2.3

?>

Resistance to the use of OOP style coding in Drupal and other PHP applications is going have more and more of an impact on the future of those projects. PHP is becoming better but only from an OOP standpoint and CMS coders risk being left behind in innovation. If they continue to try and re-invent what PHP gives as a faster and better alternative the projects will dive in popularity. Web developers want to take the easiest way out. With the coming of PHP 5.3, PHP will gain much more readablity, performance and lend more to unit testing when using OOP coding. The of the following code would do wonders to increasing the flexibility of any framework or CMS. Making the creation of module systems and scaling so much easier

<?php

namespace Foobar
;
class 
Foo {
    static public function 
test() {
        print 
"Hello world!\n";
    }
}
call_user_func(__NAMESPACE__ .'::Foo::test'); // As of PHP 5.3.0
// Hello world!
call_user_func(array(__NAMESPACE__ .'::Foo''test')); // As of PHP 5.3.0
// Hello world!

?>

But will those that are adopting PHP5 and have embraced the removal of PHP4 take the next big step. Will they turn their resources to making better software by using the tools available or will they go on making copies of those tools. Will they go on making choices that will only serve to make them dim memories as the future leaves them behind.


Happy Publishing!

php's picture
Pia Weathers - database systems engineer
Thoughtbox - So what did you think?



 
CMS Comparison Matrix

Newsletter

Get updates on Hiveminds services, articles and downloads by signing up for the newsletter.

Editor's choice

Some of the better articles, stories and tutorials found at Hiveminds.

Find more

Find more of Hiveminds articles, stories, tutorials and user comments by searching.




Picked links

Hand picked websites and articles from around the web that provide quality reading.