php语言,如何用html代码输出一个网页ob_start&&ob_end_flush

来源:互联网 发布:vscode php注释插件 编辑:程序博客网 时间:2024/04/30 13:55

php语言,如何用html代码输出一个网页

<?phpfunction callback($buffer){  // replace all the apples with oranges  return (str_replace("apples", "oranges", $buffer));}ob_start("callback");//<span class="refname">ob_start</span> — <span class="dc-title">打开输出控制缓冲</span>?>

                            <html>
                            <head>
                            <meta http-equiv="Content-Type" content="text/html; charset=GBK" />
                            <title>success</title>
                            <style type="text/css">
                            body { background:url(images/failure.jpg) no-repeat fixed 50% 5%;  }
                            </style>
                            </head>
                            
                            <body>
                            </body>
                            </html>

<?phpob_end_flush();//<span class="refname">ob_end_flush</span> — <span class="dc-title">冲刷出(送出)输出缓冲区内容并关闭缓冲</span>?>

上面的代码就可以把想要的网页完美的输出来,而不用调用一个这样代码的网页,比如用alert弹出信息时,因为alert命令使整个进程都中断,所以网页的背景不能调用现在的网页,所以用上面的代码输出以后,就可以得到想要的效果。





0 0