[RESOLVED] Problem when using php code in messages
I am having a problem here... I want to insert php code in a message (for one of the messages in the message block of the screen).
The message body is stored in a database as text. When the page is displayed, the inserted php code is treated as text too and is not runned properly... I tried different things and nothing seem to work.
Is anyone have any idea of how to do that?
This is the php code line I want to insert in my message: .strtoupper(_CURRENT_MONTH_)."SPECIALS"
Thanks in advance!
You would probably have to make use of eval(), but, "If eval() is the answer, you're probably asking the wrong question." More secure would be to just embed some sort of place-holder in there, then replace it via str_replace() or sprintf(), or printf(). E.g.:
$textFromDB = "blah blah blah _CURRENT_MONTH_ blah blah blah";
echo str_replace('_CURRENT_MONTH_', date('F'), $textFromDB);
"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
Thank you NogDog!
It worked perfectly!
I should have seen that solution... Too easy!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)