PHP to run $_SERVER in command Line could encounter a lot of issues. But instead you may run them in your project root and use browser to see the result.
Let's create a file name test.php in your project root and your code below like
Now if your run the scrept from your browswer you will see result printed.
Of course, the variables I have defined inside the PHP scripts, all belong to the project. You need to do it based on your requirements.