文件获取内容页面不支持php

文件获取内容页面不支持php,php,html,Php,Html,我正在使用我的php新站点。这里我想用php文件编写代码编写一个html页面。在这里,我使用了file\u get\u内容。例如,见下文 $page_old.="<table width='1051' border='0' cellspacing='0' cellpadding='0'>"; $page_old.="<tr><td height='50' class='tittle'>Test</td></tr>"; $page_old

我正在使用我的php新站点。这里我想用php文件编写代码编写一个html页面。在这里,我使用了file\u get\u内容。例如,见下文

$page_old.="<table width='1051' border='0' cellspacing='0' cellpadding='0'>";
$page_old.="<tr><td height='50' class='tittle'>Test</td></tr>";
$page_old.="<tr><td class='content'>My content Body</td></tr></table></td></tr>";
$page_old.=file_get_contents('../contents/footer.php');     
fwrite($fp_old,$page_old);
fclose($fp_old);
$page_old.=”;
$page_old.=“测试”;
$page_old.=“我的内容正文”;
$page_old.=file_get_contents('../contents/footer.php');
fwrite($fp_old,$page_old);
fclose($fp_old);
我的页脚页面包含一些php代码,请参见下文

<td colspan="4"><a href="../more-products.php?feat1_id=YlX>PdRf" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image49','','../images/Kluz_usa_s_over_18.jpg',1)"><img src="../images/Kluz_usa_s_18.jpg" name="Image49" width="276" height="162" border="0" alt="Universal Laser Systems VersaLASER " title="<?=$test_vra?>" ></a></td>

我想从php变量中分配title,alt src值。但结果并不正确。例如,我的标题标签显示

如何显示该php变量的实际内容

提前感谢

返回包含所提供url的HTML的字符串

如果要使用和,则需要使用fopen打开footer.php

但是你的问题对我来说没有意义。是否要用
$page\u old
覆盖footer.php?如果是这样,您可以使用并执行
文件put\u contents('../contents/footer.php',$page\u old)

返回包含所提供url的HTML的字符串

如果要使用和,则需要使用fopen打开footer.php


但是你的问题对我来说没有意义。是否要用
$page\u old
覆盖footer.php?如果是这样,您可以使用并执行
文件put\u contents('../contents/footer.php',$page\u old)
文件获取内容
将以字符串形式提供文件内容,而不是以可执行代码形式解析该文件

最简单的方法是打开输出缓冲,
包含该PHP文件以便执行,然后将缓冲区附加到
$page\u old
变量

$page_old.="<table width='1051' border='0' cellspacing='0' cellpadding='0'>";
$page_old.="<tr><td height='50' class='tittle'>Test</td></tr>";
$page_old.="<tr><td class='content'>My content Body</td></tr></table></td></tr>";

ob_start();
include('../contents/footer.php');
$output = ob_get_contents();
ob_end_clean();

$page_old .= $output;

file_put_contents('filename.html', $page_old);
$page_old.=”;
$page_old.=“测试”;
$page_old.=“我的内容正文”;
ob_start();
包括('../contents/footer.php');
$output=ob_get_contents();
ob_end_clean();
$page_old.=$output;
文件内容('filename.html',$page\u old);

file\u get\u contents
将以字符串形式提供文件内容,而不是以可执行代码的形式解析该文件

最简单的方法是打开输出缓冲,
包含该PHP文件以便执行,然后将缓冲区附加到
$page\u old
变量

$page_old.="<table width='1051' border='0' cellspacing='0' cellpadding='0'>";
$page_old.="<tr><td height='50' class='tittle'>Test</td></tr>";
$page_old.="<tr><td class='content'>My content Body</td></tr></table></td></tr>";

ob_start();
include('../contents/footer.php');
$output = ob_get_contents();
ob_end_clean();

$page_old .= $output;

file_put_contents('filename.html', $page_old);
$page_old.=”;
$page_old.=“测试”;
$page_old.=“我的内容正文”;
ob_start();
包括('../contents/footer.php');
$output=ob_get_contents();
ob_end_clean();
$page_old.=$output;
文件内容('filename.html',$page\u old);

您可能希望删除$page\u old.=文件\u get\u contents('../contents/footer.php');谢谢你指出这一点,我把它拿走了。我希望我读对了问题,很难说。谢谢。但是PHP4中是否支持file_put_contents()?否,但PHP4在任何地方都不受支持。PHP5已经有7年多的历史了。任何人都不应该运行PHP4,它在几年前就已经过时了。您可能需要删除$page_old.=file_get_contents('../contents/footer.PHP');谢谢你指出这一点,我把它拿走了。我希望我读对了问题,很难说。谢谢。但是PHP4中是否支持file_put_contents()?否,但PHP4在任何地方都不受支持。PHP5已经有7年多的历史了。没有人应该运行PHP4,它在几年前就已经过时了。