Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP读取文件内容并替换文本_Php_Regex_Codeigniter_Str Replace - Fatal编程技术网

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>