Broken file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
roflkopter
Forum Newbie
Posts: 1
Joined: Wed Dec 15, 2010 5:23 am

Broken file

Post by roflkopter »

Hi all,

I got this very weird problem while developing a webshop system. Ever since I made a file (modules.php) with an array with testdata in it, my whole project seems to be "broken". The PHP in the modules.php file is 100% correct.
The trouble started when I included the file. The array would just show as HTML and I got all kinds of crazy Chinese characters.

This is what I get on screen when I include the file:

Code: Select all

<?php
// Define all default modules

$modules = array(
					'dashboard' => array(
						'title'		=>	'Dashboard',
						'image'		=>	'home.png',
						'updates'	=>	0
					),
					'orders' => array(
						'title'		=>	'Bestellingen',
						'image'		=>	'purchases.png',
						'updates'	=>	2
					)
				);
?>戼⁲㸯㰊㹢慗湲湩㱧戯㨾†慃湮瑯洠摯晩⁹敨摡牥椠普牯慭楴湯ⴠ栠慥敤獲愠牬慥祤猠湥⁴祢⠠畯灴瑵猠慴瑲摥愠⁴㩃硜浡灰桜摴捯屳敷獢潨屰牴湵屫湩汣摵獥浜摯汵獥瀮灨㌺⤱椠戼䌾尺慸灭屰瑨潤獣睜扥桳灯瑜畲歮慜浤湩楜摮硥瀮灨⼼㹢漠楬敮㰠㹢㐳⼼㹢戼⁲㸯
And the weirdest thing about it is, that the file seems to infect other files when included. I included the file in another file just to test and I got the same as above. But when removing the include the file suddenly didnt work anymore (white page).

I tried reinstalling XAMPP, move everyting on another server, remake and retype the modules.php file a thousand times and searching but I couldnt find anything. My whole system doesn't seem to work anymore thanks to this file.


What could this be? Some weird encoding error? A virus?


Thanks in advance
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Broken file

Post by Jonah Bron »

Sounds like an encoding error. Try explicitly setting the encoding on all your files when saving to UTF-8, and set the <meta> charset to the same.

Code: Select all

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