executing code from database

前端 未结 8 547
逝去的感伤
逝去的感伤 2021-01-29 14:42

I have a PHP code stored in the database, I need to execute it when retrieved.

But my code is a mix of HTML and PHP, mainly used in echo \"\";

A sample that look

8条回答
  •  难免孤独
    2021-01-29 15:08

    use the eval() function.

    heres some info

    http://www.php.net/manual/en/function.eval.php

    something along the lines of:

    eval($yourcode);
    

    If that is the last resort, you want it to be secure as it will evaluate anything and hackers love that. Look into Suhosin or other paths to secure this in production.

提交回复
热议问题