I am designing an OOP application, it’s my first application.
I have class (similar to one mentioned below)
class Temp {
private function a() {
<code goes here>
}
private function b() {
// To call method 'a', I am using $this
$this->a();
// Is it correct?
}
}
I don’t know whether I should call another private method from a private method using $this.
Am I doing correct in above example?
Thanks.
Yes, this is correct. Private means that it is meant to be used only within the class that defines it, but not in derived classes. So in your case, you can call
aandbanywhere within yourTempclass. But if you derive another class from it, saySubTemp, you may not callaorbwithin the implementation ofSubTemp.