What are the potential pitfalls of using ereg functions in PHP, especially in comparison to preg functions?

The potential pitfalls of using ereg functions in PHP include deprecated functionality, slower performance, and limited regular expression capabilities compared to the preg functions. To avoid these pitfalls, it is recommended to switch to using preg functions for regular expression operations in PHP.

// Replace ereg function with preg_match function
if (preg_match('/pattern/', $string)) {
    // Code block
}