How can the issue of calling a function in one class from another class be resolved in PHP?

Issue: To call a function in one class from another class in PHP, you can create an instance of the class containing the function within the other class and then call the function using that instance. Example PHP code snippet:

class Class1 {
    public function myFunction() {
        echo "Hello from Class1!";
    }
}

class Class2 {
    public function callFunctionFromClass1() {
        $class1 = new Class1();
        $class1->myFunction();
    }
}

$class2 = new Class2();
$class2->callFunctionFromClass1();