0

In Yii framework I like to put image tags to a text block and store them in db. They are generated with php code. If I get back that code from the db it doesn't run. The same is true to hyperlinks. Meanwhile I understood that it is dangerous to run code from db. Is there a way to store content with hyperlinks and images in the db and get it back for rendering?

Thanks for every hint!

some text here and here the code section <?php echo 'blabal';>

I expected : some text here and here the code section blabal

but got : some text here and here the code section <?php echo 'blabal';>

1
  • PHP code and HTML code (hyperlinks, images) are two completely different things. PHP code needs to be executed on server before it's send to client. On the other side the HTML code needs to be sent to client as is. Do you really need both of those? Remember that executing php code from outside source is really bad idea from security point of view. Commented Jul 8, 2025 at 14:07

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.