What is the difference between if ($this-> _hasParam('name') and if($this->_getParam('name')), Ze
Posted
by Linto davis
on Stack Overflow
See other posts from Stack Overflow
or by Linto davis
Published on 2010-03-17T05:50:14Z
Indexed on
2010/03/17
5:51 UTC
Read the original article
Hit count: 221
zend-framework
|php
I want to check in zend, whether a posted form value 'name' contains a value.For this i have used the following code
one method
if ($this->_getPatram('name') != null ) {
echo 'field name contains value';
} else {
echo 'field name contains no value';
}
second method
if ($this->_hasParam('name')) {
echo 'field name contains value';
} else {
echo 'field name contains no value';
}
output , when submitting the form with the 'name' field contains no value
in first method
field name contains no value (result is correct)
in second method
field name contains value (result is wrong)
So what is the difference between these two ? _hasParam and _getParam
© Stack Overflow or respective owner