How can a child class in PHP access and override a method from its parent class?

To access and override a method from its parent class, a child class in PHP can simply declare a method with the same name as the parent class method. This is known as method overriding. By doing this, the child class can provide its own implementation of the method while still being able to access the parent class method using the `parent::` keyword.

class ParentClass {
    public function methodToOverride() {
        echo "Parent class method";
    }
}

class ChildClass extends ParentClass {
    public function methodToOverride() {
        parent::methodToOverride(); // Accessing parent class method
        echo "Child class method";
    }
}

$child = new ChildClass();
$child->methodToOverride();