Question

This is driving me crazy.

I have this one php file on a test server at work which does not work.. I kept deleting stuff from it till it became

<?
print 'Hello';
?>

it outputs

Hello

if I create a new file and copy / paste the same script to it it works! Why does this one file give me the strange characters all the time?

Was it helpful?

Solution

That's the BOM (Byte Order Mark) you are seeing.

In your editor, there should be a way to force saving without BOM which will remove the problem.

OTHER TIPS

Found it, file -> encoding -> UTF8 with BOM , changed to to UTF :-)

I should ahve asked before wasing time trying to figure it out :-)

Just in case, here is a list of bytes for BOM

Encoding    Representation (hexadecimal)
UTF-8   EF BB BF
UTF-16 (BE) FE FF
UTF-16 (LE) FF FE
UTF-32 (BE) 00 00 FE FF
UTF-32 (LE) FF FE 00 00
UTF-7   2B 2F 76, and one of the following bytes: [ 38 | 39 | 2B | 2F ]†
UTF-1   F7 64 4C
UTF-EBCDIC  DD 73 66 73
SCSU    0E FE FF
BOCU-1  FB EE 28 optionally followed by FF†
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top