两个ob_start();导出到单独的文件

时间:2013-10-17 13:52:19

标签: php

我的客户端服务器不支持php并且需要大量更新,因此我将页面导出为.html。现在,他想导出此页面的一部分,以便将其上传到其他地方。

我如何调用两个ob_start();,我知道它可能但我如何区分两者?

示例页面sudo代码

ob_start();  //1 obstart  

<html>
<head></head>
<body>
ob_start();   //2 obstart  
<div class="special"></div>
//stop copying obstart #2
</body>
</html>


$contentString =  ob_get_contents();
$divString =  ob_get_contents();

file_put_contents( 'HTMLFile.html', $contentString ); 
file_put_contents( 'specialDIV.txt', $divString ); 

1 个答案:

答案 0 :(得分:0)

<?php
ob_start();  //1 obstart  
?>
<html>
<head></head>
<body>
<?php
$contentString =  ob_get_contents();
ob_start();   //2 obstart 
?> 
<div class="special"></div>
//stop copying obstart #2
</body>
</html>

<?php
$divString =  ob_get_contents();

file_put_contents( 'HTMLFile.html', $contentString ); 
file_put_contents( 'specialDIV.txt', $divString ); 
?>
相关问题