Page 1 of 1

Execute PHP from database in template file?

Posted: Sun Feb 23, 2014 10:58 pm
by karlpers
Im quite new to coding, and I struggle a little with a task, so I hope someone know a simple solution on this..

In my database, I store a php script, e.g. "<?php echo $some_information; ?>"
This string is stored under $this->config->get('database_entry')

Is it then possible to run this php in the template file, instead of just printing out the content as plain text.

If I paste the php script directly in the template file, it does what it should, but if I go via the database there is only plain text as output.

So, if there would be a commando to import and run the content from the database instantly, it would be great!

Dont ask me why I would go this way instead of just add the code directly in the template file...

Really thankful if someone knows a solution!

Re: Execute PHP from database in template file?

Posted: Sun Feb 23, 2014 11:49 pm
by platoon
Yes, it is possible to execute (evaluate) string in PHP using command eval($string)
For more informations see: http://www.php.net/eval

Re: Execute PHP from database in template file?

Posted: Mon Feb 24, 2014 2:26 am
by karlpers
Thanks a lot! I will have a look into that :)