I am having problem with this code $route = ltrim(strtok($SERVER['REQUESTURI'], '?'), '/'); on page 376 of the e-book. I am using Xampp which uses apache server and my index.php is not inside the root directory is in
The line of code you quoted takes the URL e.g.
https://192.168.10.10/jokes/edit?id=4 and extracts the parts between the domain name and the question mark (if there is one, otherwise the end of the URL.
The URL i mentioned would set the
$route variable to
/jokes/edit which is then used for routing to a controller action.
index.php in a different subdirectory such as yours, the
$route variable will contain the string
You'll need to remove
/phpmysqlnoviceninja6th/Chapter09/public from the string. The simplest way is to add the line
$route = str_replace('/phpmysqlnoviceninja6th/Chapter09/public', '', $route)
There is likely a better way of working out what the extra part of the URL is from various
$_SERVER variables. However, I recommend against hosting websites like this from a single URL. You're better off setting up virtual hosts on your apache installation so that you can have , for example