note 49142 deleted from language.oop5.autoload by felipe

From: Date: Mon, 24 Mar 2008 22:30:03 +0000
Subject: note 49142 deleted from language.oop5.autoload by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137484@lists.php.net to get a copy of this message
Note Submitter: Jami Pekkanen ---- Autoloading can be abused to simulate C++-style templates: <?php function __autoload($className) { $names = explode('__', $className, 2); if(count($names) != 2) return; eval( "class $className extends {$names[0]} { public static function getTemplateValue() { return {$names[1]}; } }" ); } class Dummy {} echo Dummy__HelloWorld::getTemplateValue()."\n"; // HelloWorld $bye = new Dummy__ByeBye(); echo $bye->getTemplateValue()."\n"; // ByeBye ?> Also a great way to confuse anyone trying to read/maintain your code.

« previous php.notes (#137484) next »