如何从php调用c ++函数?

I have a c++ program which has to return a string. Since the main method in C++ cannot return a string, I am returning the string through a user-defined function. How can I invoke this function from my php script. I know exec() command can call a C++ program but is there a way I can call a specific function?

scenario:

int main()
{
   string myfunc(){
      ....
      return string;
   }
   return 0;
}

How can I call the myfunc() from PHP?

You can use C++ PHP bridge library.

Check this link

http://www.php-cpp.com/

And another extension from zend,

Check this link http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/

This will help you