How to extend PHP with C++?


Can I write a C++ code that can be compiled and used for extending PHP (I don't mean calling an executable file)? Can I describe some classes, functions and use them for in my PHP code by calling the compiled (.so or .a file) C++ code? If yes, then please explain me schematically how it is being done.




Yes, you can do so by writing a PHP extension.
See PHP at the Core: A Hacker's Guide to the Zend Engine.




The Zend engine is a good option as already mentioned in the previous answer.

Other alternative is SWIG (it supports multiple languages)

Specifically, for php with C++, you can refer to:

People are also looking for solutions to the problem: html - php inserting data with filter and validation


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.