Yes, there is something like what you are talking about. You need to learn the Zend API before you can do it though, read:
http://www.zend.com/zend/api.php
It's a pretty straightforward API. The hooks you make will call out to the library that you want to use. Of course, since PHP is compiled using gcc (not g++), you'll have to accomodate the C syntax so that it can work with C++ bindings.