If I had PHP code in the database, could I “include” that somehow in PHP and execute it?
Well, sure I could write out a file with that content and just include that file, but maybe PHP has got something similar to eval() of JavaScript?
If I had PHP code in the database, could I include that somehow in
Share
Yes, PHP has
eval()too, but it is regarded very bad practice to use it.This question discusses the major points well, without condemning it totally.
Most often, if
eval()comes up, it is worth taking a hard look at the program you’re building: There is probably a better way to do it. For example, if you want to fill data values into HTML code that is stored in a data base, a templating engine of some sort might be a better idea.