5

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

3
  • Any chance you could do something with __CLASS__ in it? php.net//manual/en/language.constants.predefined.php Commented Jun 8, 2014 at 11:20
  • __CLASS__ is for PHP at the object scope. :/ Commented Jun 8, 2014 at 11:41
  • Yeah, never tried to do what you want - was hoping you might be able to come up with some trick :) I am curious myself now that you asked it hehe Commented Jun 8, 2014 at 11:42

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.