我在这段代码中有一些令人困惑的行为:
<?php
ob_start(); ?>
<script>
jQuery(document).ready(function () {
var the_instance = jQuery('.ib_clock_instance_<?php echo ib_clocks::$shortcodes; ?>');
});
</script>
<?php
$html = ob_end_flush();
?>
它是静态编写类的一部分。由于某种原因,当调用ob_end_flush
时,数字1被添加到输出put的末尾。考虑到php文档,感觉这可能是一个布尔值true(http://php.net/manual/en/function.ob-end-flush.php),但我无论如何都看不出要抑制它。
有人知道为什么会发生这种事吗?
ob_end_flush()
直接回显输出,只返回true
或false
,因此当您回显$html
之后,您将得到1
。
要么不回显$html
:
ob_end_flush();
或者使用
$html = ob_get_flush();
echo $html;