What is the difference of getting params from $_GET or from request object?

As the topic why should i use one method above the other? I mean every get param (coming from urls also in the path format) is accesible from $_GET so why do i need the CHttpRequest::getParam method?

Convention?

In any framework in php you can access directly $_GET.

But shall make a vow to never access this way, just because php let you do this.

getParam() has the benefit to allow you specify a default value if the specified GET variable doesn't exist. As a result, you can write:

$id=Yii::app()->request->getParam('id',0);

instead of

$id=isset($_GET['id']) ? $_GET['id'] : 0;

This is the only difference.

Hi,

It seems that Yii::app()->request->getParam("user['name']","");

will always return null even though $_POST['user']['name'] is not null

Is there a way to get this working?

Quote

Hi,

It seems that Yii::app()->request->getParam("user['name']","");

will always return null even though $_POST['user']['name'] is not null

Is there a way to get this working?

maybe getParam not work with post variables square bracket notation?

Yeah, this is not supported currently. Could you please submit a ticket for this? Thanks.

Quote

Yeah, this is not supported currently. Could you please submit a ticket for this? Thanks.
done thanks

Thanks :)