I am in the framework stage of building a routing system to build a PHP framework.
I have to use to write again, for the very good URL, I found that part covered. But say that I want to create a page with URL:
www.domain.com/news/10 (news-id) /
and I want this dynamic variable (this News ID) is the name of the rewrite.
What I want to achieve;
The framework for News Controller routes, and argues as 10: $ args = array (' You can use You can get the requested news-ID from the string. Update $ _ server 10) P>
$ _ server super to inspect the requested URI Global in your example, Code> $ _ SERVER ['REQUEST_URI'] will be set as something:
/ news / 10 /
// Use the substrokes to ignore forward forward slash $ request = explosion ('/', substit ( $ _ Server ['REQUEST_URI'], 1)); $ Count = count ($ request); // At this point, $ request [0] == 'news' is required ($ count> 1 & amp; amp; intwal ($ request [1])) {// The second part of the request is not an integer 0} and no {if ($ count == 1} {// This is a request for '/ news' // The second part of the request is either not an integer or 0} and if ($ request [1] = = 'Latest') {// Show the latest news} and if ($ request [1] == 'oldest') {// Show oldest news} if ($ request [1] == 'read most') {// read more news Show}
$ _r For God
Comments
Post a Comment