php version

  • Thread starter Thread starter ragtek
  • Start date Start date

php version

  • 5.2

    Votes: 8 26.7%
  • 5.3

    Votes: 22 73.3%

  • Total voters
    30
R

ragtek

Guest
Which php version are you using?

Already php5.3 or 5.2 ?

We made the decision to use the new features of php 5.3 for our add-ons, because it makes development "faster & easier"
for example
get_called_class()
PHP:
abstract class Ragtek_Helper_Abstract{

    static private $instances = array();
    public static function getInstance(){
        $class = get_called_class();
		if (empty(self::$instances[$class]))
		{
			self::$instances[$class] = new $class;
		}
		return self::$instances[$class];
    }
}
But i think that this will result in an big "problem" for many users, because they will not be able to use these add-ons.
 
I've never seen a "useful real world php example" when to use closures (just used in in js), so i've never used them in my code, but I'm loving the late static binding.
 
mikey@aeon:~$ php -v
PHP 5.2.4-2ubuntu5.12 with Suhosin-Patch 0.9.6.2 (cli) (built: Sep 20 2010 13:33:05)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
 
I've never seen a "useful real world php example" when to use closures (just used in in js), so i've never used them in my code, but I'm loving the late static binding.
PHP:
usort($array, function($a, $b) {
    return $a - $b; // or something, y'know, more complex.
});
$text = preg_replace_callback('/\((\d+)\+(\d+)\)/', function($match) {
    return '(' . ($match[1] + $match[2]) . ')';
}, '(2+3) (10+7)');
// (5) (17) but i didn't test this at all.

Basically anyplace you use a callback, you no longer need to write a one-shot function that only serves a single basic purpose. Unless you do the unthinkable and use... create_function.
 
Top Bottom