Hope someone can help me, i am storing php in a table stored as a text field in my database as:
<?php
echo "this is a test";
?>
And i am pulling this content out of the database to be rendered using the below command in the preDispatch function of a controller:-
<?php
class Ajfit_Controller_View_Action extends Zend_Controller_Action {
public function preDispatch()
{
parent::preDispatch();
$this->getResponse()->setBody($page->getContent());
}
}
?>
My problem is the when i render the content from the database the page just displays the text of the php and does not execute it, is what I am doing even possible?
Thanks
Andrew
You would need to use eval($phpcode) for that to work. It’s a security risk if you were to accept this from untrustworthy sources.
You will also have to add:
so that ZF doesn’t try to render the view.
if you decide to use eval(), you might want to do this:
You cannot have the eval’d content wrapped in open/close PHP tags, hence the preg_replace.