Get up to 80 % extra points for free! More info:

Discussion – Lesson 3 - Router

Back

 

Comments
Avatar
Agostino I
Member
Avatar
Agostino I:7/5/2019 5:48

At the end of the article, writing:

$router->process(arra­y($_SERVER['RE­QUEST_URI']));

we are passing an array to the process function:

However to understand better what we are doing:

If I insert in the browser the URL: localhost/arti­cle/parameter1/pa­rameter2

$SERVER['REQU­EST_URI'] has the value of

"article/para­meter1/parame­ter2", that is a string right?

Passing to the process function: array($_SERVER['RE­QUEST_URI'] means

passing an array that has in 0 position the string URL right?

That is an array like this:

$example=arra­y("article/pa­rameter1/para­meter2") so in $example[0] we have the URL address right?

Reply
7/5/2019 5:48
while(1){ workHard();} but sometimes....take a rest! :)
Avatar
Reply
7/5/2019 6:35
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
Jack Holden
Member
Avatar
Jack Holden:10/21/2020 6:44

How would this work if your MVC was in a sub-directory? domain.com/mvc/con­troller/method/pa­rams etc

Thanks

 
Reply
10/21/2020 6:44
Avatar
Replies to Agostino I
Shyamender Singh Chahal:8/1/2021 2:12

use this code it check if script running in localhost than remove first element from url array that is your project folder name

if($_SERVER['RE­MOTE_ADDR']=='127­.0.0.1' or $_SERVER['REMO­TE_ADDR']=='::1' )
{

$parsedUrl = array_slice($par­sedUrl,1);

}

 
Reply
8/1/2021 2:12
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

4 messages from 4 displayed.