doddsey_65 Posted August 21, 2011 Share Posted August 21, 2011 I have a class which loads language files and adds the content(which is an array) into a phrases array. It's performed perfectly when i included common_lang.php and login_lang.php. However when i include common_lang.php and profiles_lang.php something weird happens. I have a blank space at the top of the profile pages. And firebug reports that the content of <head> is now empty and its shifted all of it to the <body>. Like i say this only happens when including profiles_lang.php but works with other files like login_lang.php. The content of each language file is the same apart from the data in the array. $l = array( 'USERNAME' => 'Username', ); this is the language class which is being called in profiles.php like Asf_Language::loadFile('profiles'); The same call is used in other pages replacing 'profiles' with the name of the language file to call. <?php /* ASF A Simple Forum * (c) ASF A Simple Forum 2010 - 2011 * * @licence http://www.asimpleforum.co.uk/licence * * $page includes/languageClass.php * $author Carl Markham * $created 14/06/2011 */ class Asf_Language { public static $lang; public static $phrases = array(); public static $loaded_langs = array(); public function __construct($default) { $this->setLang($default); self::loadFile('common'); } public static function setLang($lang) { self::$lang = $lang; } public static function getLang() { return $lang; } public static function loadFile($file) { $include = dirname(dirname(dirname(__FILE__))).'/languages/'.self::$lang.'/'.$file.'_lang.php'; if(file_exists($include)) { include($include); self::$loaded_langs[] = $file; foreach($l as $key => $val) { self::$phrases[$key] = $val; } } else { echo 'File '.$include.' does not exist'; } return; } public static function getLoadedLanguages() { return implode(', ',self::$loaded_langs); } } Anyone have any ideas why the head is being emptied when this file is being included? Quote Link to comment https://forums.phpfreaks.com/topic/245371-including-language-files/ Share on other sites More sharing options...
Muddy_Funster Posted August 22, 2011 Share Posted August 22, 2011 any chance of seeing profile_lang and any 1 other working script? Quote Link to comment https://forums.phpfreaks.com/topic/245371-including-language-files/#findComment-1260466 Share on other sites More sharing options...
doddsey_65 Posted August 22, 2011 Author Share Posted August 22, 2011 this is profiles_lang.php <?php /* ASF A Simple Forum * (c) ASF A Simple Forum 2010 - 2011 * * @licence http://www.asimpleforum.co.uk/licence * * $page languages/en/login_lang.php * $author Carl Markham * $created 27/07/2011 */ $l = array( 'WALL_FEED_DELETED' => 'Your wall feed has been deleted', 'USER_STATISTICS' => 'User Statistics', ); and this is login_lang.php <?php /* ASF A Simple Forum * (c) ASF A Simple Forum 2010 - 2011 * * @licence http://www.asimpleforum.co.uk/licence * * $page languages/en/login_lang.php * $author Carl Markham * $created 27/07/2011 */ $l = array( 'FILL_ALL_DETAILS' => 'Please fill in all details', 'NO_USER' => 'No user was found matching your data', 'WRONG_SECRET_QUESTION' => 'You entered an incorrect secret question or secret answer', 'LOGGED_IN' => 'You have now been logged in', 'LOGIN' => 'Log me in', 'FORGOT_PASS' => 'Forgot password', 'USERNAME' => 'Username', 'PASSWORD' => 'Password', 'AUTO_LOGIN' => 'Auto Login', 'USERNAME_LOGIN_INFO' => 'Enter the username you logged in with', 'PASSWORD_LOGIN_INFO' => 'The password you chose when you registered', 'AUTO_LOGIN_INFO' => 'Choose to be logged in automatically each visit', ); As i said there is no difference apart from the content of the array. Quote Link to comment https://forums.phpfreaks.com/topic/245371-including-language-files/#findComment-1260498 Share on other sites More sharing options...
Muddy_Funster Posted August 22, 2011 Share Posted August 22, 2011 Nothing there looks like it could do what you are experiencing. Unless there is some verification on the page that has the actual header info in it that has gone a bit off I'm going to have to confess to being utterly useles on this one Quote Link to comment https://forums.phpfreaks.com/topic/245371-including-language-files/#findComment-1260505 Share on other sites More sharing options...
doddsey_65 Posted August 22, 2011 Author Share Posted August 22, 2011 Thanks for the help anyway then. If it happened with each included language file then i may be able to understand. But the fact it only happens on this one included file. If i change the file to login_lang.php the space disapears and everything works fine. Quote Link to comment https://forums.phpfreaks.com/topic/245371-including-language-files/#findComment-1260507 Share on other sites More sharing options...
PFMaBiSmAd Posted August 22, 2011 Share Posted August 22, 2011 Best guess is you either have something in the file before the <?php tag or after the ?> tag or you have saved the file as a UTF-8/Unicoded file with BOM (Byte Order Mark) characters. Make sure there are no characters outside of the <?php ?> tags and make sure that file is saved without the BOM characters (there should be an option in your editor's encoding/file-save-as menu.) Quote Link to comment https://forums.phpfreaks.com/topic/245371-including-language-files/#findComment-1260510 Share on other sites More sharing options...
doddsey_65 Posted August 22, 2011 Author Share Posted August 22, 2011 ive changed the save type to utf 8 without BOM but still get the same issue. Ive since deleted the language files and resaved them to make sure this new encoding was being saved but no joy there. It still only happens with profiles_lang.php. I thought it may be the encoding of the profiles.php page which calls the file but ive tested it on the index which had no issues calling common_lang.php and I get the same thing when calling profiles_lang.php Quote Link to comment https://forums.phpfreaks.com/topic/245371-including-language-files/#findComment-1260513 Share on other sites More sharing options...
doddsey_65 Posted August 22, 2011 Author Share Posted August 22, 2011 *sigh* The preferences i changed seem only to apply to newly created documents. Ive changed the encoding for the current document and everything appears fine now. Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/245371-including-language-files/#findComment-1260517 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.