I am using the latest version of Yii and trying to basically collate the URL parameters.
For instance if my URL was as follows:
site.com/events/199/111
What is the function to grab the first parameter e.g '199' and similarly again to say grab the 2nd parameter e.g '111'.
I remember CodeIgniter has $this->url->segment(1)
, I basically need the same functionality to Yii :)
Yii::app()-request->redirect('/path/to/url');
A query string is the portion of a URL where data is passed to a web application and/or back-end database. The reason we need query strings is that the HTTP protocol is stateless by design. For a website to be anything more than a brochure, you need to maintain state (store data).
GET parameters (also called URL parameters or query strings) are used when a client, such as a browser, requests a particular resource from a web server using the HTTP protocol. These parameters are usually name-value pairs, separated by an equals sign = . They can be used for a variety of things, as explained below.
On somthing like -
$this->createUrl('blah/blahx',array('id'=>2));
You can get your parameter using -
$x = CHttpRequest::getParam('id'); //outputs x=2
OR $x = Yii::app()->getRequest()->getQuery('id'); //x=2 again
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With