Lets say that I have an array that I want to convert to a value object.
My value object class is as follows:
/* file UserVO.php*/
class UserVO
{
pu
$result[] = new $vo($data[$i]); //this obviously wont work...Class name must be a valid object or a string
Have you tried it? It works just as expected (in php 5.1, I don't know how was it with OOP in php 4, but if you are using __construct
for constructor this should work).
To avoid multiple includes define magic function __autoload
before using any class
function __autoload($className)
{
require_once 'myclasses/'.$className.'.php';
}
So first call new UserVo
will trigger this function to include file myclasses/UserVo.php.