What are some key differences between accessing object properties and array elements in PHP?

When accessing object properties in PHP, you use the arrow (->) operator followed by the property name. On the other hand, when accessing array elements, you use square brackets ([]) with the key inside. It's important to remember that objects store data in properties with names, while arrays store data in elements with keys.

// Accessing object properties
class Person {
    public $name = "John";
}

$person = new Person();
echo $person->name; // Output: John

// Accessing array elements
$colors = array("red", "green", "blue");
echo $colors[0]; // Output: red