在longtext数据中嵌入变量

时间:2012-10-07 05:11:48

标签: php mysql

是否可以在longtext字段中嵌入变量?

例如:

description(field):日期是$ date_var

PHP中的

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

输出:

The date is 10/13/2012

请指教。

1 个答案:

答案 0 :(得分:-1)

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

$ str =“日期是%s”

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

或者使用str_replace / preg_replace。不要使用eval,尤其是对数据库中的某些数据。