【发布时间】:2014-07-30 09:02:19
【问题描述】:
我正在尝试使用 PHP 解析 .php 文件,找到任何 <?php include $root.'whatever.html'; ?> 并替换为一段 html 代码。
到目前为止,我遇到了两个问题,如何将whatever.html 捕获到变量中,以及如何不将$root 变量视为本地引用。
【问题讨论】:
-
使用 file_get_contents 将 html 捕获到变量中
-
您可以从 Regex Tag Wiki 开始学习 regex:stackoverflow.com/tags/regex/info
-
$content = file_get_contents('whatever.html'); // 在这里用 $content 做某事。