Jump to content


Photo

Multilanguage application


  • Please log in to reply
4 replies to this topic

#1 Esbar

Esbar
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 17 March 2006 - 08:07 PM

Hi (:,

so, i'm going to create an application based on classes with an language selection feature. So first i did it like this

<?php

$menu = array(
              "home"=>"Home"
              );

class foo {

   final function __construct() {
      print($menu["home"]);
   }

}

?>

But ofcourse that doesn't work. It says "Variable 'menu' undefined..".
So any ideas what i should do?

#2 Esbar

Esbar
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 17 March 2006 - 10:24 PM

Just making it reach the top-

#3 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 17 March 2006 - 10:27 PM

Try defining the class variable.


<?php

class foo {

var $menu = array(
              "home"=>"Home"
              );


   final function __construct() {
      print($menu["home"]);
   }

}

?>

If that doesn't work, which i'm not sure if it will or not because i've never used an array with var try declaring it as a global.


<?php

$menu = array(
              "home"=>"Home"
              );

class foo {

   final function __construct() {

      global $menu;

      print($menu["home"]);
   }

}

?>


#4 Esbar

Esbar
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 17 March 2006 - 10:37 PM

None of that helped :(
But do you got any other suggestions how to make the language feature?

#5 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 18 March 2006 - 12:12 AM

If you have ever had to write apps in other languages for standalone....

One very useful feature is the resource file. Have a read up on resouce files. Maybe implement it via the database...
follow me on twitter @PHPsycho




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users