What are some potential pitfalls when using count() in PHP?
One potential pitfall when using count() in PHP is that it may not work as expected when dealing with variables that are not arrays or objects. To avoid this issue, you can first check if the variable is an array or object before using count() to prevent any errors.
// Check if the variable is an array or object before using count()
if(is_array($variable) || is_object($variable)) {
$count = count($variable);
// Use $count variable for further processing
} else {
// Handle the case when $variable is not an array or object
}