[英]Include a section of HTML or SSI within a PHP Script?
I'm working with making my website compliant with EU cookie directives, and on the homepage, I need help with figuring out how to include a cookie warning message, and a the script that disables Google Analytics. 我正在努力使我的网站符合欧盟cookie指令,并且在主页上,我需要帮助来弄清楚如何包含cookie警告消息,以及禁用Google Analytics的脚本。
I have made a set of preference cookies to be set for the website. 我为网站设置了一组首选cookie。
My site is made with SSIs: meta header newsletter -- page content -- footer 我的网站是用SSIs制作的:元标题简报 - 页面内容 - 页脚
In my Header SSI, before my content, immediately after my body tag opens, I need to include a small page I made to ask for consent for cookies (/inc/cookies.shtml) 在我的标题SSI中,在我的内容之前,在我的正文标记打开之后,我需要包含一个我要求同意cookie的小页面(/inc/cookies.shtml)
how would I get a php script to insert the contents of cookies.shtml? 我如何获得一个php脚本来插入cookies.shtml的内容?
somewhat wrong code I made :( : 我做的有些错误的代码:(:
<?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 /inc/cookies.shtml
<div id="cookie-outer"> cookie warning content and form to consent and stuff is here </div>
I'm pretty sure you should be putting semi-colons on the end of your statements: 我很确定你应该在你的陈述结尾处放置分号:
<?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'); }
?>
It's likely that $_COOKIE["shcpr"]
contains the string TRUE
. $_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.