Benefits of getPost over $ _POST

Are there any advantages Yii::app()->request->getPost()over $_POST?

I feel that it makes the code too object oriented.

+4
source share
1 answer

CHttpRequest::getPost() checks if the first parameter exists, and if it does not return a default value that you can pass to it.

Here is its actual implementation:

public function getPost($name,$defaultValue=null)
{
    return isset($_POST[$name]) ? $_POST[$name] : $defaultValue;
}
+8
source

Source: https://habr.com/ru/post/1527674/


All Articles