ob_start 回调函数提取输出 - PHP
我想获得输出“Apples”,因为它位于 span 标签内部,其 id 称为“fruit”。那么回调函数中应该写什么代码呢?
<?php
function callback($buffer) {
// get the fruit inHTML text, the output should be "Apples" only
....
....
}
ob_start("callback");
?>
<html>
<body>
<p>It's like comparing <span id="fruit">Apples</span> to Oranges.</p>
</body>
</html>
<?php
ob_end_flush();
?>
I would like to get output "Apples", because it is inside of span tag which has id called fruit. So what codes should be written in that callback function?
<?php
function callback($buffer) {
// get the fruit inHTML text, the output should be "Apples" only
....
....
}
ob_start("callback");
?>
<html>
<body>
<p>It's like comparing <span id="fruit">Apples</span> to Oranges.</p>
</body>
</html>
<?php
ob_end_flush();
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更通用的解决方案...
A more generic solution...