PHP include function output by unknown char

When using the include function, php, the inclusion is successful, but it also displays char before the output of the include, char has a hexadecimal value of 3F, and I do not know where this is based on this, although it seems to happen with every inclusion.

At first, I thought it was a file encoding, but that didn't seem to be a problem. I created a test case to demonstrate it: ( link no longer works ) http://driveefficiently.com/testinclude.php this file consists of only:

<? include("include.inc"); ?> 

and include.inc consists only of:

 <? echo ("hello, world"); ?> 

and yet the conclusion is: "? hello, world", where? is a char with a random value. It is this meaning that I do not know about the origin, and sometimes it slightly wraps my sites.

Any ideas on where this might come from? At first I thought that this could be due to the encoding of the files, but I do not think this is a problem.

+4
source share
6 answers

What you see is the byte order mark of UTF-8:

The presentation of the UTF-8 specification is the EF BB BF byte sequence, which appears as ISO-8859-1 รฏ "ยฟcharacters in most text editors and web browsers that are not prepared for UTF-8 processing.

Byte order sign on Wikipedia

PHP does not understand that these characters must be "hidden" and send them to the browser as if they were regular characters. To get rid of them, you will need to open the file using the "correct" text editor, which will allow you to save the file as UTF-8 without a leading specification.

Here you can find out more about this problem.

+11
source

Your web server (or your text editor) seems to include the specification in the document. I do not see a rogue character in my browser, unless I explicitly set the site encoding to Latin-1. Then I see two (!) UTF-8 specifications.

/ EDIT: from the fact that there are two specifications, I came to the conclusion that the specification is actually included by your editor at the beginning of the file. Which editor are you using? If you are using Visual Studio, you should say "Save As ..." in the "File" menu, and then select the "Save with Encoding ..." button. There select "UTF-8 without specification" or something similar.

+3
source

It does not appear on the displayed page in Firefox or IE, but you can see a funny character when you browse Source in IE

enter image description here

Is it on a Linux machine? Could you find and replace vim or sed to find out if you can get rid of 3F?

If it's on Windows, try opening include.inc with Notepad to see if the funny char is visible and can be removed.

I would also be interested to know what happens if you copy the code from include and just run it yourself.

+1
source

I see hello, world on the page you linked to. There are no problems that I see ...

I am using Firefox 3.0.1 and Windows XP. What browser / OS are you using? Perhaps this could be a problem.

0
source

The 3F symbol is actually a question mark, it is not just displayed as one.

I get the same results as Thomas, no question mark appears.

In theory, this might be some kind of problem with a web proxy, but I tend to suspect a random question mark in your PHP markup ... which you may have already fixed, so we don't see the problem.

0
source

I would also be interested to know what happens if you copy the code from enable and just run it yourself.

Note: this is a shared hosting solution, so I cannot access the shell file. However, as you see here , there are no characters that should not be, and running the same file as the script do not create this char. (The shared hosting company was from 0 inquiries, constantly informing me that this was a problem with the browser).

0
source

Source: https://habr.com/ru/post/1276531/


All Articles