PHP:从子类方法计算父类中的if语句

If I have a class that extends another class that in turn extends another class, is it possible to change how an if statement evaluates in the parent -> parent class from a specific method in the child class?

Top Level Parent Class

class MY_Controller { if ($add_assets) { /* include assets here */ } }

Middle Level Class

class Account_Controller extends MY_Controller { /* this controller determines permissions, etc. */}

Child Class

class Posts_Controller extends Account_Controller {
    public function createPDF() { $add_assets = FALSE; }
}

So in this instance can I use the createPDF() method in the Posts controller to tell the MY_Controller not to include any assets.

You could create a protected property in your parent class which is initially set to true and in your child class set it to false inside of the function and then call the parent function.