compile c program from php page and save output

Discussion in 'PHP' started by gyanu, Jun 21, 2008.

  1. gyanu

    gyanu New Member

    Jan 30, 2008
    Likes Received:
    Trophy Points:
    We have built a code to compile C program from text area built in PHP. We have tried all the commands that could be used to compile the program,
    for example exec(), system() and even the shell_exec() commands.
    The problem is still that we are not getting the output. We are sending you the code, Kindly please suggest some solution.


    echo "hi its me lalit kumar mishra";
    $t1=$_GET['t1']; // $t1 is file name of user file.

    $t2 .= '.o'; // we are creating the filename with .o extension

    $j="cd /home/wipro;"; // where the program exist.

    $s ="$j"." gcc -c $t1"; // t1 is user filename with .c extension
    $ss="$j"." gcc -o $t2 $t1"; // t2 is filename with .o extension
    $sss="$j"." ./$t2"; // getting output of c program

    echo "Output of Program= $var1";


Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice