How can the str_replace function be utilized in PHP to replace specific characters in a string?

The `str_replace` function in PHP can be used to replace specific characters in a string by specifying the character(s) to be replaced and the replacement character(s). This function takes three parameters: the character(s) to be replaced, the replacement character(s), and the original string. By using this function, you can easily modify strings by replacing specific characters with new ones.

// Original string
$string = "Hello, World!";

// Replacing ',' with '!'
$new_string = str_replace(',', '!', $string);

// Output the modified string
echo $new_string;