Can anyone explain the differences both functionally and in terms of good/bad practice whhy one of these should be preferred over the other:
$getParam = Mage::app()->getRequest()->getParam('getparam');
v
$getParam = $_GET['getparam'];
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is a significant difference between the two.
$_GETis simply an array, like$_POST. However, callingMage::app()->getRequest()->getParam('param_name')will give you access to both GET and POST (DELETE and PUT are not included here) – see code below:In addition, if the system sets other params with
Mage::app()->getRequest()->setParam(), it becomes accessible via thegetParam()function. In Magento you want to always usegetParam().