Answer the question
In order to leave comments, you need to log in
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
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.
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
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
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
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 questionAsk a Question
731 491 924 answers to any question