Apache

Executing A C++ Application Over The Internet With PHP

Unix is a powerful operating system that uses C/C++ extensively. In this article, Mitchell will use a couple of console commands, some C++ and some PHP, to show you how to create a totally integrated C++ application, which can be executed (and have its output captured) from PHP.

If you’ve ever had any exposure to Unix/Linux, then you would know that it has both C and C++ compilers built into it: GCC and G++ respectively. Unix uses these compilers extensively during program installations, makes, etc. Using a couple of console commands, some C++ and some PHP, I will show you how to create a totally integrated C++ sample application, which can be executed (and have its output captured) from PHP. I will create the C++ application, compile it, and then talk about how we can execute that application via PHP using the passthru function. In a sense, this provides access to our application over the Internet.

To get the most from this article, you should have a Unix/Linux server setup running Apache and the latest version of PHP. A good grasp of C++ (standard ANSI-compatible C++), the Unix console, and some PHP experience are also required.