A
A
alestro2015-10-04 13:35:01
PHP
alestro, 2015-10-04 13:35:01

How does mv implement pages with an odd number of variables in the query string?

How such pages are implemented:
b2f8de331d3a4ba3b07fb63eb673e080.jpg
I connect the controller and the action via $_SERVER['REQUEST_URI'], parse the url and parse the string with explod, after which the array_shift of the first two parameters (cntroller and action, respectively), and the url turns out to be
/controller/action /var1/value1, but I'm wondering how it turns out, an odd number of parameters in the query_string, there is a specific example: site_name.loc/categories/all/digital/tv
where categories is the controller, all is the method that draws the categories page, digital is the main category , tv - a sub-category of digital, but in the end it turns out nonsense. And I would like a line like: site_name.loc/categories/ - displays all categories. site_name.loc/categories/digital - specific category
Loading some standard action, or what?
Or in which direction to dig?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Sadovnik, 2015-10-04
@cyril_sadovnik

First of all, any MVC application maps the requested URL to a specific controller and action. The component responsible for this is called a router.
See what values ​​the web server passes to your application via $_SERVER . You will find there, for example, $_SERVER['REQUEST_URI'] . Try programming the behavior you described in the last question yourself.
There are many ready-made solutions , klein is one of the prettiest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question