Is it possible to execute the PHP code returned from the MySQL query result?

The problem I encountered is this: I have a MySQL table containing detailed information about the contents of the page that I want to display on my site. However, the content for one of my pages I wanted to contain some actual PHP code that must be executed, and not just printed as a string. For instance:

require_once("Class.php");
Class::Function("Some Text For a Parameter");

I want this code to be somehow executed when the SQL query is returned, but since it is standing, it just prints this text. Is there any way to achieve what I want?

Thank you in advance for your time,

Hi,

Stephen.

+3
source share
3 answers

they represent several ways to achieve storage of dynamic elements:

, PHP-, .

DSL (, ), / .

( , ), php .

,

+4
+6

I am making a variation of this in my personal CMS by creating my own bbcode. I will enclose php to evaluate inside the [code] [/ code] tags, and then when displayed I have a function that uses regular expressions to capture the contents of the code inside the [code] tags to run. He, in turn, builds the code so that it closes the text echo, runs the script, and then starts the text echo again. The explanation may be a little simplified, but you get the idea.

I would definitely avoid eval!

0
source

Source: https://habr.com/ru/post/1793716/


All Articles