普通网友 2016-08-27 22:38
浏览 388
已采纳

如何从PHP页面删除[重复]

This question already has an answer here:

I'm developing a small website and to include the header in using PHP's include() function. However directly before any code brought in from the include, there's this weird  on the page.

Here's code for page where it's happening

<!DOCTYPE html>
<html>

<head>
    <title>Things and Stuff | Source Files</title>
    <!-- Style Sheets/Scripts/Misc Stuff -->
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <link rel="stylesheet" type="text/css" href="css/gmod.css">
    <link rel="stylesheet" type="text/css" href="css/alerts.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script src="scripts/cycle.js"></script>
</head>

<body>

<?php include('./utilities/header.php'); ?>

<!-- rest of the page from here down... -->

EDIT W/ SOLUTION

I figured it out thanks to help from below. To fix I opened the file in Notepad++, set it to PHP, and at the top under Encoding, selected ANSI (found that was = to UTF-8 w/o BOM) and it worked!

</div>
  • 写回答

2条回答 默认 最新

  • dtxpz8785 2016-08-27 22:40
    关注

    Your header file contains a Byte Order Mark header, not clearly visible be text editors which understand them and do not print them.

    Compilers/parser, on the other hand, expect full ASCII, and don't understand BOM marks.

    Solution: Remove the 3 first bytes of your header file with an hex editor or a text editor set to ASCII or UTF8 without BOM encoding and it will work.

    below screenshot of the file encoded in UTF8 with BOM with 3 first chars highlighted (using frHed)

    enter image description here

    If I remove the 3 first bytes it works. OR: open with Notepad++ and change encoding to ASCII, save, voilà.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题