WalkerJetBat
WalkerJetBat

Reputation: 75

PHP - include(); makes blank line

Hey when I add include a file at tag it creates a blank line (grey) like : http://puu.sh/40mvI NOTICE: I have seen few questions like that but they didn't helped me.

<?php require("connection/mysql.php"); ?>
<?php @session_start(); ?>
<?php
if(!isset($_SESSION["language"]))
{
    header("Location: ./language/index.php");
}
else
{
    include("./language/".$_SESSION["language"]);
}
?>
<?php if ( isset($_SESSION["bay_username"]) ) { header('Location: account/'); }?>
<!doctype html>

Language file

<?php

// NoConnect
$lg["ncon_header"]                  = "Bayyak Powered sunucularına şu an bağlanılamıyor.";
$lg["ncon_text"]                    = "Lütfen biraz sonra tekrar deneyiniz. En yakın zamanda sorunu çözeceğiz. İnternet bağlantılarınızı kontrol ediniz. Diğer aygıtlarda da aynı hatayı alıyorsanız lütfen <em>[email protected]</em> adresine bu sorunu bildirin.";

?>

Upvotes: 1

Views: 2710

Answers (3)

Undry
Undry

Reputation: 447

To make it more clear. In order to avoid unneccessary blank lines, remove the closing php tag

?>

From the files that you include or require to your main file. You need to remove those tags in files that echo something. If you simple use for functional library, than there is no need in removing.

Upvotes: 0

Ronald Ara&#250;jo
Ronald Ara&#250;jo

Reputation: 1479

Do the following:

Open your PHP file in Notepad++, go to Format -> UTF-8 (without BOM)

For some reason, PHP files with UTF-8 (with BOM) generate this blank line.

I advise you to convert all your PHP files.

Upvotes: 4

Madara&#39;s Ghost
Madara&#39;s Ghost

Reputation: 174957

Not sure if it's the actual language file. But this is worth a shot anyway:

Try to omit the closing ?> on your language file. It's allowed on files which are pure PHP (with no embedded HTML), and it can solve problems in the case where there's an invisible character after the closing bracket.

Your file should look like this:

<?php

// NoConnect
$lg["ncon_header"]                  = "Bayyak Powered sunucularına şu an bağlanılamıyor.";
$lg["ncon_text"]                    = "Lütfen biraz sonra tekrar deneyiniz. En yakın zamanda sorunu çözeceğiz. İnternet bağlantılarınızı kontrol ediniz. Diğer aygıtlarda da aynı hatayı alıyorsanız lütfen <em>[email protected]</em> adresine bu sorunu bildirin.";

Upvotes: 3

Related Questions