doupu0619 2014-02-20 13:35
浏览 77
已采纳

将php文件转换为html并将其保存在服务器上

I've made a website with news, its called index.php and it gets it content using php from database. Is it possible to convert this site to pure html, ie without all the php database queries, but with only the ouptup as the user sees it after entering the website ?

  • 写回答

2条回答 默认 最新

  • dtdb99743 2014-02-20 13:38
    关注

    Yes.

    Begin your code with:

    <?php
    ob_start(function($c) {
        file_put_contents("your_html_file_here.html",$c);
        return $c;
    });
    

    With this in place, all output is saved to a file, as well as sent to the browser - you can then use this file however you need.

    For older versions of PHP:

    <?php
    ob_start(create_function('$c','file_put_contents("your_html_file_here.html",$c); return $c;'));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分