What role does the DOMNode parameter play in the domTextReplace function in PHP, and how is it passed as a reference?

The DOMNode parameter in the domTextReplace function in PHP represents the node where the text replacement will occur. To pass it as a reference, you need to use the "&" symbol before the parameter name in the function definition. This allows changes made to the DOMNode parameter within the function to be reflected outside of the function.

function domTextReplace(&$node, $search, $replace) {
    if ($node->nodeType === XML_TEXT_NODE) {
        $node->nodeValue = str_replace($search, $replace, $node->nodeValue);
    } else {
        foreach ($node->childNodes as $child) {
            domTextReplace($child, $search, $replace);
        }
    }
}