How can functions of one class be accessed from another class in PHP without using inheritance?

To access functions of one class from another class in PHP without using inheritance, you can create an instance of the class containing the functions within the other class. This allows you to call the functions of the first class through the instance variable.

class Class1 {
    public function function1() {
        echo "Function 1 called";
    }
}

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

$class2 = new Class2();
$class2->accessFunctionFromClass1(); // Output: Function 1 called