fread() and shell_exec() are returning the same string but when I compare them, it is not working in my PHP code

Viewed 30
$fileCode=fopen('code.cpp','w+');
    fwrite($fileCode,$code);
    fclose($fileCode);
    putenv('C:\Program Files\CodeBlocks\MinGW\bin');
    shell_exec('cd C:\xampp\htdocs\codeland');
    shell_exec('g++ -o code.exe code.cpp');
    $userOutput=shell_exec('code.exe < testInput.txt');
    $outputHandle=fopen('testoutput.txt','rb');
    $output=fread($outputHandle,filesize('testoutput.txt'));
    fclose($outputHandle);

    echo $output;
    echo "<br>";
    echo $userOutput;
    echo "<br>";

    if($output==$userOutput)echo "Accepted!!!";

In my code though $output and $userOutput are showing same string but I can not get 'Accepted' .They are showing same string but actually they are not equal. What is the problem here?

0 Answers
Related