数据库中的模板
<p>This is the <strong>default </strong>CKEditor installation.{$name} Source editing is provided by the Source Editing Area</a> plugin.</p><p>Follow the{$city}steps below to try it{$country}out:</p><ul><li>Click the <strong>Source </strong>button to display the HTML source of this tex {$website} {$email}in the source editing area.</li><li>Click the <strong>Source </strong>button again to return to the WYSIWYG view.</li></ul><form>First name:<br>
以上我保存在数据库中的HTML代码。所有变量($ name,$ city,$ country,$ website,$ email)应替换为以下对象,并创建新的html模板并保存到数据库。
[
{
"name": "Lijo",
"city": "Banglaore",
"country": "India",
"website": "",
"email": ""
},
{
"name": "Thoams",
"city": "Chennai",
"country": "India",
"website": "",
"email": ""
}]
这似乎是处理这种事情的一种奇怪的方法,但是无论什么都会浮上水面。您可以使用replace()
查找模板中的占位符并将其替换为对象中的值。