-4

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;
Uzair Vawda
  • 37
  • 1
  • 9

2 Answers2

2

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'];

Zak
  • 6,976
  • 2
  • 26
  • 48
0

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

Lucas Meine
  • 1,524
  • 4
  • 23
  • 32