如果文件包含在页面开头,如何在页面上的特定位置回显包含文件的内容?
插件.php:
<?php $txt = 'HELLO WORLD';?>
<div id="pl">
... some stuff.. <?php echo $text; ?>
</div>
主.php:
<?php
include 'plugin.php';
?>
<body>
<div>SOME TEXT BEFORE THE OUTPUT...</div>
<div><?php //content of included file goes here ?></div>
</body>
<?php
$text = include 'plugin.php';
?>
<body>
<div>SOME TEXT BEFORE THE OUTPUT...</div>
<div><?php echo $text;//content of included file goes here ?></div>
</body>
您可以将包含文件的上下文存储在变量中。例如,试试这个。
你可以
简单地做
<body>
<div>SOME TEXT BEFORE THE OUTPUT...</div>
<div><?php include 'plugin.php'; ?></div>
</body>
希望对:)有所帮助
ob_start();
include($path);
return ob_get_clean();
这就是帮助。