How can you efficiently replace specific text patterns in a string using PHP functions?

When you need to replace specific text patterns in a string in PHP, you can use the `str_replace()` function. This function takes three parameters: the text pattern you want to replace, the replacement text, and the original string. You can use this function to efficiently replace multiple occurrences of a specific text pattern in a string.

// Example code to replace specific text patterns in a string
$text = "Hello, World!";
$pattern = "Hello";
$replacement = "Hi";
$new_text = str_replace($pattern, $replacement, $text);

echo $new_text; // Output: Hi, World!