I know you can technically make PHP extension just by making a PHP file and using
You can incorporate a stand-alone C/C++ program into your PHP site simply by executing it and passing the output to the browser. As far as truly inter-operating, it's not worth your time to write a library containing site-specific functionality. This simply isn't done except to interface with other existing libraries (MySQL, imagemagick, etc).
Programming for the web isn't like application development. Optimizing bits of your code by writing them in "faster" languages (analogous to writing small, tight looping bits of your C++ program in assembly) isn't worth the development time. You're better off keeping your application easily maintainable, this is why scripting languages dominate the web.