1
Vote

solution of how to cast to an arbitrary class

description

PHP maintains a generic empty class stdClass from which all class are built in PHP. You can use that class to create generic class objects anytime you wish.
 
<code>
$class = new stdClass();
$class->randomProperty1 = 'foo';
$class->randomProperty2 = 'bar';
</code>
 
Aditionally, PHP5 supports object cloning. http://us2.php.net/manual/en/language.oop5.cloning.php

comments