PHP读取文件内容并替换文本
我正在使用PHP读取文件内容并替换文本,php,regex,codeigniter,str-replace,Php,Regex,Codeigniter,Str Replace,我正在使用codeigniter作为一个框架,我想打开一个文件并以字符串形式返回内容,然后替换一些文本 我正在使用codeigniter的read\u file()以字符串形式返回文件内容。不过,我将替换该模板中的大量文本,因此执行str_replace()或regex()可能会很麻烦 不过,该文件将是一个html模板 例如:html_template.php <html> <body> Name : {{name}}<br /> Email: {
codeigniter
作为一个框架,我想打开一个文件并以字符串形式返回内容,然后替换一些文本
我正在使用codeigniter
的read\u file()
以字符串形式返回文件内容。不过,我将替换该模板中的大量文本,因此执行str_replace()
或regex()
可能会很麻烦
不过,该文件将是一个html模板
例如:html_template.php
<html>
<body>
Name : {{name}}<br />
Email: {{email}}<br />
Address: {{address}}
</body>
</html>
谢谢 OMG的可能副本!谢谢你,阿努普!正是我需要的!!!您是否检查了codeigniter用户指南中的模板解析器?
<html>
<body>
Name : John Smith<br />
Email: john.smith@example.com<br />
Address: somewhere
</body>
</html>