我想知道是否有一种方法可以在这样的回声中要求另一个php文件:
<?php
echo "
<label>Post Notifications</label>
<div>
<?php require_once('libraries/notifications/post_notifications.php'); ?>
</div>";
?>
I know the <?php require_once('libraries/notifications/post_notifications.php'); ?> isn't correct but just hope you can get the idea. Thank you!
答案 0 :(得分:1)
使用ob_get_contents
。这些标签之间的所有内容都存储在变量端清理。
ob_start();
include('libraries/notifications/post_notifications.php');
$output = ob_get_contents();
ob_end_clean();
所以看起来输出如下:
<?php
echo "
<label>Post Notifications</label>
<div>
{$output}
</div>
";
?>