gpt4 book ai didi

php - 如何删除网页脚本中的\ufeff 字符?

转载 作者:技术小花猫 更新时间:2023-10-29 12:45:41 26 4
gpt4 key购买 nike

简单地说,我试图在我的脚本中删除一个隐藏的零宽度换行符 (U+FEFF)。它出现的网页位于http://cynicode.co.uk。 (请注意,索引页已经过修改,是目前唯一可以正常运行的页面)

通过查看页面上的 html 元素,可以看到:

enter image description here

关键点是 < body > 之间的红点和 < !--5-- > .当悬停在上面时,表明它是一个 \ufeff。特点。问题是,当我查看脚本时,不存在这样的字符。

我正在使用 PHP 和 HTML 构建此页面,以及 < !--4-- > 之间的项目和 < !--5-- >由以下组成。首先,在实际索引页面本身:

<?php
echo "<!--4-->";
echo "<head><meta charset='utf-8' /><link rel='shortcut icon' type='image/ico' href='./images/CyniCode.ico'>
<title>CyniCode :: Index</title>
<meta name='description' content='The Cynic's paradise! Home of Cynical.' />
<meta name='author' content='Cynical' />
<meta name='keywords' content='Cynical;Blog;Code' />
<link type='text/css' rel='stylesheet' href='./css/mystyle.css' />
<link rel='shortcut icon' type='image/ico' href='./images/CyniCode.ico'>
<link href='http://fonts.googleapis.com/css?family=Muli' rel='stylesheet' type='text/css' />
<script type='text/javascript' src='http://static.proofiction.net/jquery/jquery-1.9.1.min.js'></script>
<script type='text/javascript' src='http://static.proofiction.net/jquery/loginwait.js'></script>
<script type='text/javascript' src='http://static.proofiction.net/jquery/googleAnalytics.js'></script>
<script type='text/javascript' src='./http://static.proofiction.net/jquery/jquery.bxslider.js'></script>
<script type='text/javascript' src='./http://static.proofiction.net/jquery/jquery.bxslider.min.js'></script>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'><!--
google_ad_client = 'ca-pub-xxxxxxxxxxxx';
/* BiggerNavBox */
google_ad_slot = '3977705372';
google_ad_width = 300;
google_ad_height = 600;
//-->
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-xxxxxxxx-1', 'cynicode.co.uk');
ga('send', 'pageview');
</script>

</head>";
require_once './functions/page.php';

这构成了索引页面。引用的 page.php 脚本是我快速、干净地设置页面的秘诀。但是......页面上的两条评论之间还有一点差异。这是两个评论之间剩下的差异。

<?php
echo "<!--5-->";

任何人都可以提供任何帮助,我们将不胜感激。所有代码片段都是从我的脚本中直接复制和粘贴的。

最佳答案

您的一些 .php 文件(可能是 ./functions/page.php 包含 Byte Order Mark。如果您使用某些 IDE , 检查此文件的编码属性,如果幸运的话,您将能够将其删除。

编辑 如果您使用 *nix,Elegant way to search for UTF-8 files with BOM?应该有帮助。

关于php - 如何删除网页脚本中的\ufeff 字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18029992/

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