- str_replace: documentation ( source)
- preg_replace: documentation ( source)
<?php
$api_link = 'https://api.drupal.org/api/drupal/8.9.x/search/';
$error = [
'message' => 'The "path.alias_manager" service is deprecated. Use "path_alias.manager" instead. See https://drupal.org/node/3092086',
];
$formatted_error = preg_replace('!deprecated function ([^(]+)\(\)!', 'deprecated function <a target="_blank" href="' . $api_link . '\1">\1()</a>', $error['message']);
$formatted_error = str_replace('\\', '\\<wbr>', $formatted_error);
$formatted_error = preg_replace('!See (https://drupal.org(.\S+)).$!', 'See <a href="\1">\1<a>.', $formatted_error);
print $formatted_error;