So i am new to oo php and i-m building a sample app for learning purpses , one thing i must do is load a language file according to some settings The code, as you will discover below is divided between two classes , a settings class witch should load the language file and another class in this case "contact" witch should read the array in the language files and display the propper message. this is the Settings class the lang variable sets the default language it can take 2 values at the moment : ro- for romanian and en - for english ,
class Settings
{
static public $lang = 'ro';
static public $load;
static public function get_language()
{
if(self::$lang == 'ro')
{
self::$load = require 'ro.php';
}
elseif(self::$lang == 'en')
{
self::$load = require 'en.php';
}
return self::$load;
}
}
The second class :
class Contact extends Settings {
//proprietati
public $nume;
public $subiect;
public $mesaj;
public $dincs;
//comportament - metode
public function __construct()
{
//$this->dincs = 'Din construct';
parent::get_language();
}
public function write_file()
{
if(empty($this->nume))
{
return $mess['name_error'];
}
else
{
$fp = fopen('data.txt', 'w');
fwrite($fp, $this->nume.".".$this->subiect .".". $this->mesaj."|".$this->dincs ."|".parent::$load);
fclose($fp);
return $mess['file_written'];
}
}
}
A sample from the language file:
$mess = array ("name_error" => "You must insert your name",
"file_written" => "the file has been written",
);
I have looked up on google , and tried some other stuff and can't seem to get it to work , and that may be because i am approaching this problem incorectly. Plese help.