S
S
Shaman7392015-07-24 09:17:26
PHP
Shaman739, 2015-07-24 09:17:26

How to make a CNC with dynamic parameters?

Hello! I have a question about CNC. There is a site.ru/articles page that has several parameters, such as month and year. That is, pages can be
site.ru/articles?month=10 or
site.ru/articles?year=2015 or
site.ru/articles?year=2015&month=10 or
site.ru/articles without parameters.
It turns out that if you make the CNC, you must always enter all the parameters, otherwise the
site.ru/articles/2015 and site.ru/articles/10 pages will consider that the year is entered
How to make the CNC recognize when the month is entered, and when the year?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alex Khizhniy, 2015-07-24
@mendler

site.ru/articles/2015, 2015 - year, 0 - month
site.ru/articles/2015/10, 2015 - year, 10 - month
site.ru/articles/0/10, 0 - year, 10 - month.

S
Shaman739, 2015-07-24
@Shaman739

it turns out that you must always pass both variables. With the year and month, I gave an example. Variables can also contain strings that the user entered, and it will not be possible to determine the variable by the length of the string

D
Dmitry Kovalsky, 2015-07-24
@dmitryKovalskiy

IMHO - there is a hardcode solution - to distinguish it yourself in the code. 2 digits - month, 4 - year, but this will not insure against the user entering 12, thinking it is a year

L
lnked, 2015-07-24
@lnked

Specifically, in your case, you can count the number of characters, that is, for a year it is 4 characters for a month from 1 to 2
, and then links of this type site.ru/articles/2015/10, site.ru/articles/10/2015 will work

T
trevoga_su, 2015-07-24
@trevoga_su

www.phpinfo.su/articles/practice/chpu_na_php.html
there is 2 example for you just

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question