How does the concept of object-oriented programming (OOP) and class inheritance play a role in resolving issues related to accessing functions in PHP?

In PHP, accessing functions can become cumbersome when dealing with multiple functions and classes. To resolve this issue, object-oriented programming (OOP) and class inheritance can be used to organize functions into classes and allow for easier access and management.

// Define a parent class with a shared function
class ParentClass {
    public function sharedFunction() {
        echo "This is a shared function.";
    }
}

// Define a child class that inherits from the parent class
class ChildClass extends ParentClass {
    // Additional functions specific to the child class
    public function childFunction() {
        echo "This is a function specific to the child class.";
    }
}

// Create an instance of the child class and call the shared function
$childObj = new ChildClass();
$childObj->sharedFunction();