在PHP脚本中包含HTML或SSI的一部分


Include a section of HTML or SSI within a PHP Script?

我正在努力使我的网站符合欧盟cookie指令,在主页上,我需要帮助了解如何包含cookie警告消息和禁用谷歌分析的脚本。

我已经为网站设置了一组偏好cookie。

我的网站是用SSI制作的:meta头球新闻稿--页面内容--页脚

在我的标题SSI中,在我的内容之前,在我打开身体标签后,我需要立即包含一个我制作的小页面,以征求对cookie的同意(/inc/cookies.shtml)

如何获得一个php脚本来插入cookies.html的内容?

我做了一些错误的代码:(:

<?php
if ($_COOKIE["shcpr"] == TRUE)
/* If the user has agreed to accept cookies, just stop this script or whatever */
{die()}
else
/* If the shcpr  cookie value is not TRUE, include the warning box */
{include 'inc/cookies.shtml'}
?>

/inc/cookies.shtml 公司

<div id="cookie-outer"> cookie warning content and form to consent and stuff is here </div>

我很确定您应该在语句末尾加分号:

<?php
   if ($_COOKIE["shcpr"] == TRUE)
   /* If the user has agreed to accept cookies, just stop this script or whatever */
   { die(); }
   else
   /* If the shcpr  cookie value is not TRUE, include the warning box */
   { include('inc/cookies.shtml'); }
?>

很可能$_COOKIE["shcpr"]包含字符串TRUE

<?php
if ($_COOKIE["shcpr"] == "TRUE")
/* If the user has agreed to accept cookies, just stop this script or whatever */
{die();}
else
/* If the shcpr  cookie value is not TRUE, include the warning box */
{include 'inc/cookies.shtml';}  
?>