[SOLVED] Include(), strange symbols

Alles, was PHP betrifft, kann hier besprochen werden.

[SOLVED] Include(), strange symbols

Postby aMess » 12. June 2010 16:30

Hi guys,

I just picked up PHP again, after not having scripted for about a year. So I downloaded XAMPP to set up a testing environment. My PHP scripts seem to work properly, except for the fact that the includes won't work. I've read several topics about this problem, but my problem is entirely different. As soon as I include a PHP file, the rest of my script is converted in some sort of strange Chinese symbols.

Code fragment for include:
Code: Select all
...include ("pass.php");
$c = checkPass("ai","caramba");...


Pass.php:
Code: Select all
<?php
   function checkPass($username, $password){
      if($username == "foo" && $password == "bar"){
         return true;
      }
   }
?>


Outcome:
戼⁲㸯㰊㹢慆慴牥潲㱲戯㨾†慃汬琠湵敤楦敮⁤畦据楴湯愠摤⤨椠戼䌾尺牂浡塜䵁偐硜浡灰桜摴捯屳慂捬湯㉹楜摮硥瀮灨⼼㹢漠楬敮㰠㹢㜲⼼㹢戼⁲㸯

Page source:
<?php
function checkPass($username, $password){
if($username == "bram" && $password == "boe"){
return true;
}
}
?>戼⁲㸯㰊㹢慆慴牥潲㱲戯㨾†慃汬琠湵敤楦敮⁤畦据楴湯愠摤⤨椠戼䌾尺牂浡塜䵁偐硜浡灰桜摴捯屳慂捬湯㉹楜摮硥瀮灨⼼㹢漠楬敮㰠㹢㜲⼼㹢戼⁲㸯


Any idea what might cause this problem?

Thanks in advance!

-aMess
Last edited by aMess on 13. June 2010 13:29, edited 1 time in total.
aMess
 
Posts: 2
Joined: 12. June 2010 16:06

Re: Include(), strange symbols

Postby aMess » 13. June 2010 13:28

Hi guys,

It's me again. I think I've found the solution.
It appears my text editor used so called BOM's, Byte order marker. Because of these markers, the files weren't interpreted properly. So I got these Chinese like symbols. The solution is to save your files using the UTF-8 Encoding Type without BOM's. It worked for me... ;)

-aMess
aMess
 
Posts: 2
Joined: 12. June 2010 16:06


Return to PHP

Who is online

Users browsing this forum: No registered users and 1 guest