Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
231 views
in Technique[技术] by (71.8m points)

php - How do I remove a ufeff character in my webpage scripts?

I am trying to, simply put, remove a hidden zero-width-line-break character (U+FEFF) in my script. The webpage that it has appeared on is at http://cynicode.co.uk (Please note, the index page has been tinkered with and is the only one which functions properly at the moment)

By looking at the html elements on the page, this shows up:

enter image description here

The key point being the red dot between < body > and < !--5-- >. This, when hovered over, shows that it is a ufeff character. The problem is that, when I look through the script, there is no such character that exists.

I am using PHP and HTML to construct this page, and the items between < !--4-- > and < !--5-- > consists of the following. Firstly, on the actual index page itself:

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

This constitutes for the Index page. The page.php script referenced is my cheat for setting the page up quickly and cleanly. However... there is a small remaining difference between the two comments on the page. This is the remaining difference between the two comments.

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

Any help that anyone can offer would be much appreciated. All code pieces were direct copy and pastes from my scripts.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Some of your .php files (probably ./functions/page.php contains Byte Order Mark. If you are using some IDE, check this file's encoding properties and with luck you will be able to remove it.

Edit If you use *nix, Elegant way to search for UTF-8 files with BOM? should help.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...