executing code from database

前端 未结 8 459
逝去的感伤
逝去的感伤 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:27

    You can execute code with eval():

    $code_str = "echo 'Im executed'";
    eval($code_str );
    

    BUT PAY ATTENTION that this is not safe: if someone will get access on your database he will be able to execute any code on your server

提交回复
热议问题