note 80720 deleted from function.unserialize by aharvey

From: Date: Tue, 06 Nov 2012 01:33:47 +0000
Subject: note 80720 deleted from function.unserialize by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191714@lists.php.net to get a copy of this message
Note Submitter: rhm31 at cam dot ac dot uk ---- Problem: I needed a way to call an object that I did not know the name of. This forced me to use a variable for the class name. Solution: unserialize(); GACK! This is imaginative, but horrid. Firstly, I thought this would work: $object=new $class_name(); Otherwise, something like below will work: $object=eval("new $class_name()"); You can use a normal constructor this way too.

« previous php.notes (#191714) next »