PHP function trying to include from domain root not working [closed]

I made the following PHP function:

function root_include($path) {
    include $_SERVER['DOCUMENT_ROOT'] . $path;
}

and then I added

root_include('/elements/text.php');

but it doesn’t work.

I was trying to include from the domain root, not the server root, and I am kind of a PHP noob so please educate me on what I did wrong.

EDIT: So apparently it does work, but I just can’t get any variables from the included file.

I can get variables from /elements/text.php with

include $_SERVER['DOCUMENT_ROOT'] . '/elements/text.php';

but not when I use the function for some reason, even though it’s supposed to be the same