I have a language class with public data members:
class language {
public $error = "There was an error";
}
Then I have many different classes that uses this class. How can I access this class from within other classes? You could of course instantiate an object of it inside all the classes that uses it, but I suppose that would drastically decrease the performance, if I were to do that with multiple classes.
I do only need one object, since I don't change them anyway. So, I've done
$language = new language();
class name {
private $language;
public function __construct() {
global $language;
$this->language = $language;
}
public function method() {
mysql_query(...) or die($this->language->error);
}
}
Is this a good way to do it? Now I have to instantiate it in every "mother" script. And I suppose by doing __construct() I'm only passing a refrence, since I don't use the clone word?