I'm very new to PhP oop.I'm trying to make a small project here is my code:
class Language {
public $hello;
public $greetings;
public function english(){
echo $this->hello = "Hello" . "<br>";
echo $this->greetings = "Greetings" . "<br>";
}
public function british(){
echo $this->hello = "Ello there mate!" . "<br>";
echo $this->greetings = "Oi ya cheeky bugger" . "<br>";
}
}
$language = new Language;
echo $language->english();
echo $language->british();
How can I echo the variable $hello but only from 1 of the funcions? I really don't get the how I'm suppose to do it here.
Basically I want to grab $hello from english() and echo it out inside a
<p></p>
Or something along those lines
Can someone point me in the right direction?
$this->hello. From outside,$language->hello. Or do you want to call it through a method?