gpt4 book ai didi

php - <iframe> 而不是包含

转载 作者:可可西里 更新时间:2023-11-01 00:36:49 25 4
gpt4 key购买 nike

我想使用 Commentics 在一页上包含多个评论部分PHP 脚本。首先,我尝试使用 include 完成此操作像这样:

<div id="1">  
<?php
include "comments_id1.php";
?>
</div>
<div id="2">
<?php
include "comments_id2.php";
?>
</div>

comments_id1.php:

<?php 
session_start();
ob_start();
?>
[...]
<?php
$page_id = "1";
$reference = "Page One";
$path_to_comments_folder = "comments/";
define ('IN_COMMENTICS', 'true');
require $path_to_comments_folder . "includes/commentics.php";
?>

(相应的 comments_id2.php:$page_id = "2"; $reference = "Page Two")

显然(值得注意的是,当涉及到 PHP 时,我仍然一无所知),这不起作用或至少会导致各种麻烦(例如“警告:无法修改 header 信息 - header 已发送”)。

所以我想到的解决方案是使用 <iframe>标签,像这样:

<div id="1">  
<iframe width="100%" src="comments_id1.php"></iframe>
</div>
<div id="2">
<iframe width="100%" src="comments_id2.php"></iframe>
</div>

现在我的问题是:这甚至是任何人都会推荐的有效解决方案吗?如果是这样,使用 <iframe> 会产生任何重大后果(除了搜索引擎)吗?为了这个目的?如果这不是要走的路,有什么建议吗?

谢谢!

最佳答案

出于多种原因,我个人非常讨厌 IFRAME,因此我建议远离它们。

你读过Commentics' integration guide吗? ?

看来你得放

<?php
session_start();
ob_start();
?>

在页面的开头,以及

<?php
$page_id = "1";
$reference = "Page One";
$path_to_comments_folder = "comments/";
define ('IN_COMMENTICS', 'true'); //no need to edit this line
require $path_to_comments_folder . "includes/commentics.php"; //no need to edit this line
?>

你想发表评论的地方。还有一个 extended integration guide .

关于php - &lt;iframe&gt; 而不是包含,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5597375/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com