I\'m new to OOP and I can\'t figure out why this isn\'t working. Is it not ok to instantiate a class with in a class. I\'ve tried this with included file with in the method an
You can access your private method with the help of create another public function in the same class and call the private function in the public method or function. Now you can call your private function with the help of $run instance.
For example:
class Cars{
function getting(){
echo ("Hello World");
}
private function getting2(){
echo ("Hello World Againg");
}
public function getting3(){
$this->getting2();
}
}
$class_object=new Cars;
print($class_object->getting3());
Your output screen like the below image.