从PHP-CPP的Php :: Value中检索类名

mcu*_*ros 5 php c++ php-extension php-cpp

使用PHP-CPP处理PHP的小扩展,我在C++端接收一个带有对象的数组,我需要检索它的类名.对象Php :: Value看起来没有任何方法.

与我在此扩展中的HNI类似:https: //github.com/mcuadros/bson-hni/blob/master/src/encode.cpp#L86

Mar*_*tto 4

你是对的,在 Php::Value 对象中没有特殊的方法来确定 C++ 中的类名。因此,确定类名的最佳方法是使用 Php::call 方法来调用 PHP 用户空间中的 get_class 方法:

std::string classname = Php::call("get_class", object);
Run Code Online (Sandbox Code Playgroud)

其中 object 是上述数组中的对象之一。