How can one access properties from one class in another class in PHP?

To access properties from one class in another class in PHP, you can use getter and setter methods or make the properties public. Getter methods allow you to retrieve the value of a property from one class in another class, while setter methods allow you to set the value of a property. Making the properties public allows them to be accessed directly from another class.

class Class1 {
    private $property = 'value';

    public function getProperty() {
        return $this->property;
    }
}

class Class2 {
    public function accessPropertyFromClass1() {
        $class1 = new Class1();
        echo $class1->getProperty(); // Output: value
    }
}

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