如何将命名空间设置为stdClass的实例


How to set a namespace to the instance of stdClass?

我需要将对象的类型从stdClass更改为"myClass",所以像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);

预期结果:myClass

我需要像上面的函数:"get_class",但行为像"set_class"。

我需要像上面那样的函数:"get_class",但行为像"set_class"。

我短:在PHP中没有类强制转换,但我不知道,如果这是真的是你的问题

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

在我看来,如果你提供了正确的类名,就不需要再进行类强制转换了。

PDOStatement: fetchObject ()