Reputation: 37243
I have little strange behavior.
my div have spaces when i insert a function . forexample :
if i put this
include ('header.php');
$view->header_login();
setlanguage(); // <--------this is my language function
i get space like that
if i remove that function
include ('header.php');
$view->header_login();
//setlanguage();
i get this
Here is my function
function setlanguage(){
if(!isset($_SESSION['selectlang'])){$_SESSION['selectlang'] = 'English' ;}
if(!isset($_GET['lang'])){$_GET['lang'] = 'english' ;}
switch ($_GET['lang']){
case "english" :
$_SESSION['selectlang'] = 'English';
include("lang/english.php");
break;
case "swedish" :
$_SESSION['selectlang'] = 'Swedish';
include("lang/swedish.php");
break;
case "russian":
$_SESSION['selectlang'] = 'Russian';
include("lang/russian.php");
break;
default :
include("lang/english.php");
}
}
EDIT:
english.php
<?php
define("NEW_GOOD_NAME_CONSTANT", "I have a value");
define("Free_website", "talking website");
define("Home", "Home");
?>
Upvotes: 0
Views: 64
Reputation: 27852
In your english.php
, there spaces after the closing ?>
?>
^^^^^^^^^^
You don't need the closing ?>
, so just drop it, the entire file would then look like:
<?php
define("NEW_GOOD_NAME_CONSTANT", "I have a value");
define("Free_website", "talking website");
define("Home", "Home");
You may also have an UTF-8 BOM (byte-order-mark) in your files, you can check this on a UNIX/Linux box with:
$ head -c3 sleep | hexdump -C
00000000 ef bb bf |...|
If your output is similar to this (0xef 0xbb 0xbf), then there's a BOM present. The BOM is interpreted as whitespace by PHP.
On Windows, you'll need to use a HEX editor to check this.
Removing this depends on your editor, you should find a setting "save with BOM", or something to that effect, and disable it. This page also lists a number of methods to remove a BOM.
Upvotes: 3
Reputation: 12027
The same thing happened to me.
I found out that it has to do with the method of encoding when using Notepad++. UTF-8 without BOM
seemed to work.
However, I found a workaround to it since I preferred UTF-8
and it should work:
<span style="display: none"><?php include ('header.php'); ?></span><?php
$view->header_login();
setlanguage();
Upvotes: 3