Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve class name from a Php::Value at PHP-CPP

Working on a small extension for PHP using PHP-CPP, I receive at C++ side, an array with objects and I need retrieve the class name of it. The object Php::Value didn't looks like have any method for it.

Similar as i do at HNI in this extension: https://github.com/mcuadros/bson-hni/blob/master/src/encode.cpp#L86

like image 236
mcuadros Avatar asked Oct 01 '22 15:10

mcuadros


1 Answers

You are right, there is no special method to determine the classname in C++ in the Php::Value object. The best way to determine the classname is thus to use the Php::call method to call the get_class method in PHP userspace:

std::string classname = Php::call("get_class", object);

Where object is one of the objects in the mentioned array.

like image 163
Martijn Otto Avatar answered Oct 18 '22 00:10

Martijn Otto