假设我有以下文件 - template.php
:执行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()对不对? – 2009-11-05 22:02:40
我做了,谢谢你指出。 – EvilChookie 2009-11-05 22:11:25