Executing PHP code from mysql
Does anybody know another method of executing php code from a mysql result.
Is the eval() function the only way?
If so, is using it for a cms safe since only the webmaster will be using it?
Any information regarding this issue is greatly appreciated.
I'm a believer in "If eval() is the answer, you're probably asking the wrong question." (Attributed to the creator of PHP.)
Why do you want/need PHP code in the database in the first place? A better understanding of that might lead us to a better solution.
In general, I'd rather store any/all code in PHP files, perhaps as function definitions that can be require()'d. Then if for some reason you need to use info from the database to control what code gets executed, you would, for example, just store a function name or parameter or whatever in the DB, and use that to control what code gets executed or how it gets executed.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)