0

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.

2
  • very interesting stackoverflow.com/questions/5063490/how-to-extend-tcl-with-c Commented Feb 21, 2011 at 8:04
  • Yes, TCL and PHP are for very wide range, but sometimes they are too slow. This solves C++. So the combination of these 2-3 programming laguages give a REAL POWER!!! Commented Mar 26, 2012 at 15:00

2 Answers 2

4

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

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

Comments

2

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:

http://www.swig.org/Doc1.3/Php.html

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.