What are potential pitfalls when using references in PHP?

One potential pitfall when using references in PHP is accidentally modifying the original value when working with references. To avoid this, always be mindful of when you are passing variables by reference and ensure that you are not inadvertently altering the original value.

// Example of potential pitfall when using references
$originalValue = 5;
$referenceValue = &$originalValue;
$referenceValue = 10;

echo $originalValue; // Output will be 10, as $originalValue was modified through $referenceValue
```

To avoid this pitfall, you can make a copy of the original value before working with references:

```php
// Avoiding pitfall by making a copy of the original value
$originalValue = 5;
$copyValue = $originalValue;
$referenceValue = &$copyValue;
$referenceValue = 10;

echo $originalValue; // Output will be 5, as the original value was not modified