这里需要一些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;
}
Run Code Online (Sandbox Code Playgroud)
这输出:
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()返回当前缓冲区的内容.
| 归档时间: |
|
| 查看次数: |
12008 次 |
| 最近记录: |