<?php
//This concept is used in online judges.
$file = $_POST['filename'];//A file which is upload by user
$piece = explode(".",$file);//Extract the extension part of file.
$length = sizeof($piece);
//We can use this code for another language changing only in compiler
if($piece[$length-1]==="c")
{
exec("gcc $file -o output");
exec("./output < arguments", $out);//Arguments which is useful in program and make $out
for ($i=0; $i <sizeof($out); $i++)
{
echo $out[$i];
}
}
?>
This code is very useful for making the online judge using php(For checking the output).
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.