php – 在ob_start()中使用include()
发布时间:2020-12-13 16:01:48 所属栏目:PHP教程 来源:网络整理
导读:这里需要一些 PHP帮助,包含的内容显示为’1′,这意味着它的真实但需要它的内容才能显示,我不确定它为什么不是.这是一个缩短版的函数: public function content { $website-content = 'Some content here. '; ob_start(); include('myfile.php'); $file_cont
这里需要一些
PHP帮助,包含的内容显示为’1′,这意味着它的真实但需要它的内容才能显示,我不确定它为什么不是.这是一个缩短版的函数:
public function content { $website->content = 'Some content here. '; ob_start(); include('myfile.php'); $file_content = ob_end_clean(); $website->content .= $file_content; $website->content .= ' Some more content here.'; echo $website->content; } 这输出: Some content here 1 Some more content here 当我需要输出时: Some content here 'Included file content here' Some more content here 我有什么想法可以解决这个问题吗?
尝试使用ob_get_clean()而不是ob_end_clean().
两者都清除当前缓冲区但ob_end_clean()返回一个布尔值,而ob_get_clean()返回当前缓冲区的内容. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |