tags:

views:

41

answers:

3

Let's say I have saved this kind of data (some text '.date(d).' some text) to SQL (with htmlspecialchars()). Now, if I restore htmlspecialchars, is there a way for me to have PHP fill in the date?

Basically I guess what I'm asking is, is there way to turn text into php string?

+1  A: 

If you mean executing a string as PHP code, you can use eval()

kemp
If eval() is the answer, you're almost certainly asking the wrong question. -- Rasmus Lerdorf
mdm
+1  A: 

eval() evaluates a string as PHP code, but be careful - it can destroy all of your work (or some of it as well) if you're not sure what the string contains!

Björn
+3  A: 

You can always eval() a string, but the possible security implications of this are very grave, so I wouldn't recommend it.

If it's a particular expression, you can substitute it - say, @@date@@ would get string-replaced with an actual date(d) result.

MaxVT
This is actually a language file that I would like to move from PHP to MYSQL but I need it to be somewhat dynamic. Since no one would be able to add/edit the data that goes through eval(), would it be OK?