Selecting a langauge for a website

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
Icethrill
Forum Newbie
Posts: 13
Joined: Fri Jan 02, 2009 9:55 am

Selecting a langauge for a website

Post by Icethrill »

So here's the thing got a piece of code that checks if your swedish or not. It worked before but now somehow it never loads the page. I tested the thing with echo's if it dont jump in the if correctly. It works and puts out the correct information. Have tried somethings to go around this but it dont work. So I am looking if you guys can see if somethings wrong with the code.

Code: Select all

<?php
    session_start();
    $tmp = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
    //$pos = strrpos($tmp, "-");
    $lang = substr($tmp, 0, 2);
 
    if(!isset($_SESSION['user_lang'])) {
        if($lang == "sv" || $lang == "SV") {
            header("location: se/");
            echo "hej";
        }
        $_SESSION['user_lang'] = $lang;
        echo "hej";
    }
    
    echo $lang;
    
?>
Icethrill
Forum Newbie
Posts: 13
Joined: Fri Jan 02, 2009 9:55 am

Re: Selecting a langauge for a website

Post by Icethrill »

anyone at all? this thing is giving me a headache! :banghead:

With header-list I get this information in the output:

Code: Select all

array(2) { [0]=>  string(23) "X-Powered-By: PHP/5.2.6" [1]=>  string(23) "Content-type: text/html" } ?


And with header-sent I get this output:

Code: Select all

Headers were already sent in /Users/maas/Sites/jamesway/index.php on line 1
I dont know if this is saying anything of whats wrong though... any ideas?
Post Reply