Search code examples
phpmysqlevallaravel-5.4

eval() in laravel not executing the string


My database table contains an eloquent query click here to see Database Table Snapshot .I have fetched the query from database.Now problem is that I'm unable to execute the query that is in the collection. I have Tried eval() to execute the query present the collection.But eval() is not executing it.

  eval("\"$tempdata\";");

$tempdata contains the query that is in the database table.


Solution

  • You need to add return when using eval.

    Try:

    eval("return $tempdata;");