What is the equivalent function in PHP to Perl's s/// regex substitution?

In PHP, the equivalent function to Perl's s/// regex substitution is the preg_replace() function. This function allows you to perform regular expression search and replace operations on a string. You can specify the pattern to search for, the replacement text, and the input string to operate on. By using preg_replace(), you can achieve the same functionality as Perl's s/// substitution in PHP.

$input_string = "Hello, World!";
$pattern = '/Hello/';
$replacement = 'Hi';

$output_string = preg_replace($pattern, $replacement, $input_string);

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