0

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!

FirstOrderKylo
  • 99
  • 2
  • 11
  • 1
    Please show the contents of the header file. – Chris Aug 27 '16 at 22:39
  • 6
    This is the best for you: [http://stackoverflow.com/questions/3255993/how-do-i-remove-%C3%AF-from-the-beginning-of-a-file](http://stackoverflow.com/questions/3255993/how-do-i-remove-%C3%AF-from-the-beginning-of-a-file) – Provie9 Aug 27 '16 at 22:40
  • It has to be in header file – Tonza Aug 27 '16 at 22:51

2 Answers2

4

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à.

Jean-François Fabre
  • 131,796
  • 23
  • 122
  • 195
1

Check your PHP file encoding. Try using UTF8 without boom, and make sure your php has no empty spaces at the top of the file.

Asmir Zahirovic
  • 267
  • 2
  • 10