简体   繁体   English

发送前如何在服务器上处理HTML

[英]How to process HTML on server before sending

I want to run a script to process the HTML of a web page just before output - after all PHP and other server side scripts have finished running - adding meta and doing other subtle changes. 我想在输出之前(在所有PHP和其他服务器端脚本完成运行之后)运行脚本来处理网页的HTML,添加元数据并进行其他细微更改。 This is on linux with apache server. 这是在带有apache服务器的linux上。 Is there a standard way to do this? 有标准的方法吗?

I have read about output filters in apache . 我已经阅读了关于apache输出过滤器的信息。 Is this the right way to go? 这是正确的方法吗?

Thanks 谢谢

I think you are talking about Output Buffering : you can tell php to start buffering your output using ob_start(); 我认为您在谈论输出缓冲 :您可以告诉php使用ob_start();开始缓冲输出ob_start(); then after you finish buffering your content you can send it to the browser as a whole using ob_end_flush(); 然后,在您完成内容缓冲后,可以使用ob_end_flush();将其作为一个整体发送到浏览器ob_end_flush(); , an example: , 一个例子:

<?php
// start output buffering at the top of our script with this simple command
ob_start();
?>

<html>
<body>
<p>Hello world!</p>
<?php echo "<p>Hello again!</p>"; ?>
</body>
</html>

<?php
// end output buffering and send our HTML to the browser as a whole
ob_end_flush();
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 发送到服务器之前如何处理表单数据? - How to manipulate form data before sending to server? 在发送前如何在php的新闻通讯中修改html链接? - how to modify html links in a newsletter in php before sending them out? 在发送之前将联系人发送到不同的服务器/域 - Sending contact for to different server/domain before sending 在“加载”内容之前,如何首先处理和显示html的外层? - How to process and display the outer layer of html first before 'loading' the content? 如何让我的 html 电子邮件表单在发送到 php 脚本进行发送之前使用 javascript 进行验证 - How to I get my html email form to validate using javascript before sending it to the php script for sending 将HTML代码发送到服务器并下载 - Sending HTML code to server and download it 发送前从输入中删除 HTML 标签 - Remove HTML tags from input before sending 将变量设置为在发送电子邮件之前以HTML格式设置 - Set variable to be formatted in HTML before sending email Codeigniter-处理从数据库中检索到的值,然后将其发送到视图中 - Codeigniter - process a retrieved values from DB before sending them into a view "在 Yii2 中发送之前如何获取 HTML 电子邮件内容?" - How do I get HTML email content before sending in Yii2?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM