开发者

How to set a namespace to the instance of stdClass?

开发者 https://www.devze.com 2023-03-23 05:13 出处:网络
I need to change the type of object from stdClass to \"myClass\", so 开发者_运维问答like does PDO::fetch_object(\"myClass\");

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()

0

精彩评论

暂无评论...
验证码 换一张
取 消