【发布时间】:2009-11-05 21:29:52
【问题描述】:
假设我有以下文件 - template.php:
<?php $string = 'Hello World!'; ?>
<html>
<head>
<title>Test Page!</title>
</head>
<body>
<h1><?= $string; ?></h1>
<p>You should see something above this line</p>
</body>
</html>
我知道我可以使用file_get_contents() 将文件的内容作为字符串获取,然后我可以根据需要对其进行操作。但是,file_get_contents() 不执行 PHP 语句。
我已成功使用 cURL 来访问文件的渲染版本,但它似乎相当缓慢且笨拙,为页面的执行增加了相当多的时间 - 我想这是由于 DNS正在执行查找。
那么,我怎样才能将template.php 的内容变成一个字符串 - 同时在那里有可用的 PHP?
【问题讨论】:
-
你的意思是 file_get_contents() 对吧?
-
我做到了,感谢您指出这一点。