我不会那么多使用PHP而且现在我遇到了问题.我需要将webbrowser的网站保存为pdf.我现在正在使用mPDF(在stackoverflow的wiki中提出)并且它似乎工作得很好(我只是简单地将一个简短的html代码写入php变量然后创建了pdf).
但是现在我必须在浏览器中获取实际站点的html代码并将其保存到php变量中.我怎样才能做到这一点?
如果我理解正确,您可以将页面内容存储到php变量中,如下所示:
ob_start();
// your html code goes here
$contents = ob_get_contents();
ob_end_clean();
// see the contents now
echo $contents;
Run Code Online (Sandbox Code Playgroud)
您可以通过PHPs file_get_contents()-function获取远程内容:
$html = file_get_contents('http://example.org');
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,请确保已allow_url_fopen在php.ini中启用.
| 归档时间: |
|
| 查看次数: |
11482 次 |
| 最近记录: |