PHP不打印当前URL [重复]

This question already has an answer here:

I am starting to build my own MVC using PHP and I am trying to get the current URL in order to create a routing system. I am following a video and the code is as follows. However, it isn't working.

<?php
// phpinfo();
echo "15";
$url = $_GET['url'];
// echo $url;
</div>

You are mistaking $_SERVER['REQUEST_URI'] for $_GET['url']

$_GET['URL'] is a get statment .. Meaning you need to pass a variable through the URL IE http://example.com?URL=myurl

To get the current URL .. Simply use echo $_SERVER['REQUEST_URI'];

$_GET will get you the get parameters, not the entire url. Use $_SERVER['REQUEST_URI'] for that.