-2

我需要将对象的类型从 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”这样的行为。

4

1 回答 1

1

我需要像上面这样的函数:“get_class”,但具有像“set_class”这样的行为。

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

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

据我所知,如果您提供正确的类名,则不再需要类强制转换。

PDOStatement::fetchObject()

于 2011-07-25T12:23:10.123 回答