Re: register globals on

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Zbigniew Szalbot wrote:
Hello again,

On Tue, 12 Sep 2006, Chris wrote:

I thought I would ask your opinion before we make any decision. Is it
really so that without register globals, such things as displaying
information from databases based on the initial choice of languages is not
an option? I am not a programmer so I just need general guidance.
Complete rubbish. He's being lazy.

Thanks a lot! Any hint what to use instead? I mean I will tell him to
re-think things but with techi guys I would simply feel better saying we
need to rework the website using...???

No real hint about what to use instead, we don't know the code.

At a guess he's doing something like:

<?php

$lang_file = $lang . '.php';
include($lang_file);

....


What he should be doing:

<?php
$default_language = 'en';
$valid_languages = array('en', 'fr');

if (isset($_GET['lang'])) {
  $lang_chosen = $_GET['lang'];
} else {
  $lang_chosen = $default_language;
}

if (!in_array($lang_chosen, $valid_languages)) {
  $lang_chosen = $default_language;
}

include($lang_chosen . '.php');

....


What that does is checks to see if there is a 'lang=' in the url.

If there is, it makes sure it's valid (in this case either 'en' or 'fr').

If it's not set or it's not valid, then it uses the default language ('en').

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux