The variable PATH_INFO
is even common in Apache, but not every server will own it, because it is not always configured (depending on each server), basically you have to configure it manually, in your case you are probably using php-built-in-server, be the case or not to get the path can use the $_SERVER['REQUEST_URI']
The "problem" of $_SERVER['REQUEST_URI']
is that it returns querystring as well, for example if the URL is like this:
http://127.0.0.1:8080/edsa-Site/index.php?foo=bar
Will return this:
/index.php?foo=bar
And of course, this is much more than the way to solve this can use explode
, preg_replace
, substr
+strpos
, but my suggestion is to use something simpler, the strtok
, getting something like:
$requri = strtok($_SERVER['REQUEST_URI'], '?');
var_dump($requri);
I did the test on the built-in php server, and it worked, now using Devserver 17 I can no longer use PATH_INFO. Is there any way to configure the same one to use? I want to be able to do some tests, but I need to use a database, and with the server embedded in php I can’t make use of a database as far as I know.
– Medivh
@Medivh devserver17 is not even a server, it is a package of programs recommend that you read https://answall.com/a/115690/3635 ... do not need to use PATH_INFO, use the code that is in the answer.
– Guilherme Nascimento