Jump to content

Unwanted symbol as a result of require()

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
14 replies to this topic

#1
tmatematikas

tmatematikas

    Newbie

  • Members
  • PipPip
  • 16 posts
Hello. I am having an annoying problem with php function require(). First of all, look at the files (All utf-8 encoded).

index.php
<?php

	echo '

<html>

	<head>

		<meta http-equiv="Content-Language" content="en"/>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

		<title>require() test</title>

	</head>

	<body>';

	

	require ("body.php");

	

	echo '

	</body>

</html>';


?>

body.php
<?php

	

	echo	'

		<p>Test...</p>

		<hr>

		<table border="0" width="100%">

			<tr align="left" width="100%">

				There is a <b>""</b> symbol at the end of <b>body</b> tag. But why?

			</tr>

		</table>

		<hr>

		<br>';


?>

The problem is, that including something from another file using require() or include() generates unwanted symbol "". You probably do not see it, but copy and paste it to Notepad or smth and you will see.
Here is the the result:
<html>

	<head>

		<meta http-equiv="Content-Language" content="en"/>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

		<title>require() test</title>

	</head>

	<body>

		<p>Test...</p>


		<hr>

		<table border="0" width="100%">

			<tr align="left" width="100%">

				There is a <b>""</b> symbol at the end of <b>body</b> tag. But why?

			</tr>

		</table>


		<hr>

		<br>

	</body>

</html>
If I am just eching the code in the same index.php, everything is fine.
Any suggestion how to fix this (remove that symbol).
P.S. require() or include() must be there.

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I just tested it and I see no symbol. require() test

#3
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
It could be your server admin playing games or something.

#4
tmatematikas

tmatematikas

    Newbie

  • Members
  • PipPip
  • 16 posts
Maybe you are right. Check this: tmatematikas(dot)mikrovisata(dot)net/test/.
Oh, I forget to say, wamp gives the same.

#5
tmatematikas

tmatematikas

    Newbie

  • Members
  • PipPip
  • 16 posts
And more: it is no matter what the encoding of index.php is. I found, that ONLY the file's, which is included, encoding makes sence. If body.php is utf-8 - the symbol appears, if ansi - no symbol. Strange thing.
Jordan, make sure body.php is utf-8.

#6
Guest_Jordan_*

Guest_Jordan_*
  • Guests

tmatematikas said:

Maybe you are right. Check this: tmatematikas(dot)mikrovisata(dot)net/test/.
Oh, I forget to say, wamp gives the same.

I'm confused, I don't see any symbol. Do you want to see the symbol between the " " or not? Can you attach a screenshot of what you see?

#7
tmatematikas

tmatematikas

    Newbie

  • Members
  • PipPip
  • 16 posts
Here it is.

Attached Files

  • Attached File  adot.PNG   44.17K   30 downloads


#8
farouqzaib

farouqzaib

    Newbie

  • Members
  • Pip
  • 3 posts
I see nothing

#9
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I suspect the symbol is an artifact of Notepad, and not a character being sent.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#10
tmatematikas

tmatematikas

    Newbie

  • Members
  • PipPip
  • 16 posts
Are you blind (thank's God WingedPanther sees it)? :confused: Then make a simple Webpage with echoing <!DOCTYPE... and other stuff in a way I have mentioned and try to validate it. As I did. W3C says it is that character in prolog and it is not alowed. Try to validate my homepage (remove /test/), which address is seen in the picture. How would you explain that?

#11
tmatematikas

tmatematikas

    Newbie

  • Members
  • PipPip
  • 16 posts
Ok kids. I found the answer myself. PHP while echoing prints a Byte Order Mark (BOM) symbol at the beginning of the string. That is because my files was saved in utf-8. Notepad++ gives the ability to save a utf-8 file without BOM. I did that and that „dot“ (which is BOM to be precise) disappear. So that's the solution - convert file from utf-8 to utf-8 without BOM. I hope this would be useful for you to know in the future.

#12
tmatematikas

tmatematikas

    Newbie

  • Members
  • PipPip
  • 16 posts
More info there:
1. Error Message Feedback - Dev Archives
2. Javascript/PHP byte-order mark problem - ObjectMix Forum