EntropySink
Technical & Scientific => Programming => Topic started by: ober on October 01, 2013, 10:11:58 PM
-
I mainly run the content on one page for a site but the owner wants to be able to completely manage the page. There are a few random PHP items like the price of a subscription that I currently embed via PHP so he can change it once via a config page and it is reflected everywhere. But now that I'm storing the text for the page in the database, how can I force it to execute that PHP when displaying the blocks of the page??
To clarify, he puts in:
"the price is <?=$app->getSubscriptionPrice?>."
Right now it just prints that string as-is to the page. I want that PHP call executed. Is that possible??
By the way, I've goggled tons and come up empty so hopefully I'm missing something simple.
-
Obviously read and think about all the potential security issues but: http://php.net/manual/en/function.eval.php
I would generally favor something like a template system over that thought.
-
your time permitting, i agree with mike. templates stored in db is the way to go. avoid eval.
I've used mustache (http://mustache.github.io/) for a similar requirement. It's very simple, which is great, and it has a PHP port.
-
I would be more concerned about security if it was more than the owner using this and if anything was being submitted to this page.
I also tried using eval last night but I obviously was doing something wrong.