문제

I need to change the type of object from stdClass to "myClass", so like does PDO::fetch_object("myClass");

$inc = new stdClass;
$inc = funct_for_set_type_of_object("myClass"); // here the function to do 
                                                // namespace conversion
echo get_class($inc);

Expected result:myClass

I need function like above: "get_class", but with behaviour like "set_class".

도움이 되었습니까?

해결책

I need function like above: "get_class", but with behaviour like "set_class".

I short: There is no class cast in PHP, but I don't know, if this is really your problem

$x = $pdo->fetchObject($classname);

As far as I can see there is no need for a class cast anymore, if you provide the right class name.

PDOStatement::fetchObject()

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top