#1 2. August 2008 PHP 5.3 alpha1 released! 01. August 2008 - Frei übersetzt von Murdoc Beispiel 1: late static bindings PHP: <? php class foo { public static function getClassName () { print __CLASS__ ; } public static function selfGetClassName () { self :: getClassName (); } public static function staticGetClassName () { static:: getClassName (); } } class bar extends foo { public static function getClassName () { print __CLASS__ ; } } bar :: selfGetClassName (); //foo bar :: staticGetClassName (); //bar ?> Beispiel 2: __callStatic PHP: <? php class foo { public static function __callStatic ( $func , $params ) { print 'keine methode mit dem namen "' . $func . '" vorhanden!' ; } } foo :: undefined (); //keine methode mit dem namen "undefined" vorhanden ?> Beispiel 3: Lambda funktionen PHP: <? php //wichtig, lambda-funktionen benötigen ein ";" am ende! $foo = function() { print '$foo aufgerufen!' ; }; $foo (); //$foo aufgerufen function getLambda ( $x ) { return function( $y ) use( $x ) { print $y + $x + 1 ; }; } $foo = getLamdba ( 1 ); $foo ( 1 ); //3 class foo { public $x ; public function getLambda () { return function( $y ) { print $y + $this -> x ; }; } } $foo = new foo ; $foo -> x = 1 ; $bar = $foo -> getLambda (); $bar ( 1 ); //2 /* * folgendes ist nicht dokumentiert * funktioniert scheinbar auch ned: * $foo = (function($y) { return 1 + $y; };)(1); print $foo; //2 function times($times, $callback) { for($i = 0; $i < $times; $i++) $callback($i); } times(5, function($i) { print $i . '<br />'; };); */ //was hierbei rauskommt is mir unklar^^ //ich schätz mal anonymus# oder _lambda# $foo = function() { print __FUNCTION__ ; }; $foo (); ?> quelle: PHP: Hypertext Preprocessor + Multi-Zitat Zitieren