What are the potential pitfalls of using preg_match versus strpos for searching for a specific string pattern in PHP?

Using preg_match for searching a specific string pattern in PHP can be slower and more resource-intensive compared to using strpos, especially for simple string searches. This is because preg_match is designed for more complex pattern matching using regular expressions, which can be overkill for simple string searches. To improve performance and efficiency, it's recommended to use strpos when searching for a specific string pattern in PHP.

// Using strpos for simple string search
$string = "Hello, World!";
$pattern = "Hello";

if (strpos($string, $pattern) !== false) {
    echo "Pattern found in string.";
} else {
    echo "Pattern not found in string.";
}