I hope you have a solution. But just in case, if you do not try this:
I created a table with two columns

//$result Contains the data fetched from the table using a model. foreach ($result as $key=>$val) { if($key == 'code') { $val = str_replace('<?php','',$val); //Remove PHP opening tag. $val = str_replace('?>','',$val); //Remove PHP closing tag. $val = rtrim($val); //Remove leading and trailing spaces. echo $key.': '; eval($val.';'); //Execute the PHP code using eval. } else { echo $key.': '.$val.PHP_EOL; } }
I have tried
echo $result['code']print_r($result)var_dump($result)highlight_string($result['code'])eval($result['code'])- and finally
str_replace and then eval($result['code']) .
Check out the screenshot of the result:
hereThere you can see that the Result created by 1,2 and 5 is empty. But when you check an element for empty space, it will clearly show that the line in which the echo / print is performed is commented out.
Screen-shot .
This has nothing to do with codeigniter. This is done using HTML Parser . So the solution is to remove the opening and closing tags of PHP, and then use eval. Hope this helps.
source share