You are here:

PHP5/Integrate API


Hello ,
This is Vandan Pathak from india.
actually i just want to develop a website using that can able to  compile C & C++ programs online.
So from where i can start it?

Thank You
Vandan Pathak


The most simple way to do this is to create a C/C++ file with the needed code and run exec() function which would run the compiler. A very crude script to get you started would look like this:


echo '<form method="post">';
echo '<textarea style="width:400px;height:400px;" name="code">'.@$_POST['code'].'</textarea>';

if (isset($_POST['code'])) {
 // create cpp file
 file_put_contents('compile.cpp', $_POST['code']);
 // display compilation output
 echo system('g++ compile.cpp');

echo '<br />';
echo '<input type="submit" value="Compile" />';
echo '</form>';


You should play around and experiment with it to understand better what's going on. Also, note that in the example I used the 'g++' command which runs the UNIX/Linux C++ compiler. If you will be testing on a windows server, you must change it to a proper executable path or command, and of course, whichever system you try it on, must have a compiler installed and the webserver to be allowed to execute it.

Read more about exec() and similar functions and possible server limitations here:

Good luck and have fun coding!


All Answers

Answers by Expert:

Ask Experts




I can answer about PHP4 to PHP5 variables, arrays, GET, POST, COOKIES, FTP, sockets, mail, guestbooks, MySQL, HTML/JavaScript integration, object-oriented programming, content management systems, complex databases.


Over five years of development and studying. Have done a many applications, which included MySql, Javascript and sockets. Also some games.


Second year study

Past/Present Clients
I had a few portal order, guestbooks, administration panels and alike.

©2016 All rights reserved.