本文整理汇总了PHP中Zend_Filter::isZip方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter::isZip方法的具体用法?PHP Zend_Filter::isZip怎么用?PHP Zend_Filter::isZip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Filter
的用法示例。
在下文中一共展示了Zend_Filter::isZip方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _validateLocalSearch
/**
* Validate Local Search Options
*
* @param array $options
*/
protected function _validateLocalSearch($options)
{
$valid_options = array('appid', 'query', 'results', 'start', 'sort', 'radius', 'street', 'city', 'state', 'zip', 'location', 'latitude', 'longitude');
if (!is_array($options)) {
return;
}
$this->_compareOptions($options, $valid_options);
if (isset($options['results'])) {
if (!Zend_Filter::isBetween($options['results'], 1, 20, true)) {
throw new Zend_Service_Exception($options['results'] . ' is not valid for the "results" option.');
}
}
if (isset($options['start'])) {
if (!Zend_Filter::isBetween($options['start'], 1, 1000, true)) {
throw new Zend_Service_Exception($options['start'] . ' is not valid for the "start" option.');
}
}
if (isset($options['longitude'])) {
if (!Zend_Filter::isBetween($options['longitude'], -90, 90, true)) {
throw new Zend_Service_Exception($options['longitude'] . ' is not valid for the "longitude" option.');
}
}
if (isset($options['latitude'])) {
if (!Zend_Filter::isBetween($options['latitude'], -180, 180, true)) {
throw new Zend_Service_Exception($options['latitude'] . ' is not valid for the "latitude" option.');
}
}
if (isset($options['zip'])) {
if (!Zend_Filter::isZip($options['zip'])) {
throw new Zend_Service_Exception($options['zip'] . ' is not a valid for the "zip" option.');
}
}
$locationFields = array('street', 'city', 'state', 'zip', 'location', 'lon');
foreach ($locationFields as $field) {
if (isset($options[$field]) && $options[$field] != '') {
$locations[] = 1;
}
}
if (!is_array($locations) && $options['latitude'] == '' && $options['longitude'] == '') {
throw new Zend_Service_Exception('You must enter a locale to search near.');
}
if (!in_array($options['sort'], array('relevance', 'title', 'distance', 'rating'))) {
throw new Zend_Service_Exception('You have entered an invalid sort property.');
}
}
示例2: testZip
/**
* Returns value if it is a valid US ZIP, FALSE otherwise.
*
* @param mixed $key
* @return mixed
*/
public function testZip($key)
{
if (!$this->keyExists($key)) {
return false;
}
if (Zend_Filter::isZip($this->_source[$key])) {
return $this->_source[$key];
}
return FALSE;
}
示例3: testZip
/**
* Returns value if it is a valid US ZIP, FALSE otherwise.
*
* @param mixed $key
* @return mixed
*/
public function testZip($key)
{
if (Zend_Filter::isZip($this->_source[$key])) {
return $this->_source[$key];
}
return FALSE;
}
示例4: testIsZip
public function testIsZip()
{
$this->assertTrue(Zend_Filter::isZip('90210'), '"90210" is a valid zip code');
$this->assertFalse(Zend_Filter::isZip('9501'), '"04600" is not a valid zip code');
}
示例5: isZip
/**
* Returns value if it is a valid US ZIP, FALSE otherwise.
*
* @param mixed $key
* @return mixed
*/
public function isZip($key)
{
return Zend_Filter::isZip($this->_source[$key]);
}
示例6: testZip
/**
* Returns value if it is a valid US ZIP, FALSE otherwise.
*
* @param mixed $key
* @return mixed
*/
public function testZip($key = null)
{
if (!($value = $this->keyExists($key))) {
return false;
}
if (Zend_Filter::isZip($value)) {
return $value;
}
return FALSE;
}