Im making a project that will execute a PHP code in a string..Since im not using any PHP compiler or interpreter..I decided to use eval() function.. Im using Codeigniter Framework
MY CODE
CONTROLLER
$code = $this->input->post('code');
$functionCall = $this->input->post('funCall');
$expOut = $this->input->post('expectedOutput');
$integrate = $code." ".$functionCall;
ob_start();
eval($integrate);
$ret = ob_get_contents();
ob_end_clean();
if($ret === $expOut){
//all work fine
}
else{
redirect('main/wrongCode');
}
}
Everything work fine but when the output is fatal error..it will not execute the redirect('main/wrongCode');
..
Is there's a way to get the fatal error? So i can make a condition?