trim slashes from Request_Uri trim slashes from Request_Uri php php

trim slashes from Request_Uri


The trim function returns the trimmed string. It doesn't modify the original. Your third line should be:

$url = trim($url, '/');


This can be done in one line...

echo trim($_SERVER['REQUEST_URI'], '/');


You need to do:

$url = trim($url, '/');

You also should just do

echo $url;

It is faster.