繁体   English   中英

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

[英]Include a section of HTML or SSI within a PHP Script?

我正在努力使我的网站符合欧盟cookie指令,并且在主页上,我需要帮助来弄清楚如何包含cookie警告消息,以及禁用Google Analytics的脚本。

我为网站设置了一组首选cookie。

我的网站是用SSIs制作的:元标题简报 - 页面内容 - 页脚

在我的标题SSI中,在我的内容之前,在我的正文标记打开之后,我需要包含一个我要求同意cookie的小页面(/inc/cookies.shtml)

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

我做的有些错误的代码:(:

<?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';}  
?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM