What are common pitfalls when defining and accessing arrays in PHP?

Common pitfalls when defining and accessing arrays in PHP include using incorrect syntax for array declaration, accessing array elements using incorrect keys or indexes, and not checking if an array element exists before accessing it to avoid errors.

// Define an array with correct syntax
$myArray = array('apple', 'banana', 'cherry');

// Access array elements using correct keys or indexes
echo $myArray[0]; // Output: apple

// Check if an array element exists before accessing it
if (isset($myArray[1])) {
    echo $myArray[1]; // Output: banana
}