'embed variable in longtext data [duplicate]

Is it possible to embed variable in a longtext field?

For instance:

description(field): The date is $date_var

in PHP:

$date_var = date('m/d/Y');
echo $row['description'];

Output:

The date is 10/13/2012

Please advise.



Solution 1:[1]

http://php.net/manual/en/function.sprintf.php

$str = "The date is %s"

echo sprintf($str, date('m/y/d'));

Or use str_replace/preg_replace. Don't use eval, especially on some data from a DB.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matthew Scragg