当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Filter_Digits::filter方法代码示例

本文整理汇总了PHP中Zend_Filter_Digits::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter_Digits::filter方法的具体用法?PHP Zend_Filter_Digits::filter怎么用?PHP Zend_Filter_Digits::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Filter_Digits的用法示例。


在下文中一共展示了Zend_Filter_Digits::filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if $value contains a valid Eividencial namber message
  *
  * @param  string $value
  * @return boolean
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     if (null === self::$_filter) {
         /**
          * @see Zend_Filter_Digits
          */
         require_once 'Zend/Filter/Digits.php';
         self::$_filter = new Zend_Filter_Digits();
     }
     $valueFiltered = self::$_filter->filter($value);
     $length = strlen($valueFiltered);
     if ($length != 10) {
         $this->_error(self::LENGTH);
         return false;
     }
     $mod = 11;
     $sum = 0;
     $weights = array(6, 5, 7, 2, 3, 4, 5, 6, 7);
     preg_match_all("/\\d/", $valueFiltered, $digits);
     $valueFilteredArray = $digits[0];
     foreach ($valueFilteredArray as $digit) {
         $weight = current($weights);
         $sum += $digit * $weight;
         next($weights);
     }
     if (($sum % $mod == 10 ? 0 : $sum % $mod) != $valueFilteredArray[$length - 1]) {
         $this->_error(self::CHECKSUM, $valueFiltered);
         return false;
     }
     return true;
 }
开发者ID:hYOUstone,项目名称:tsg,代码行数:40,代码来源:Nip.php

示例2: testBasic

 /**
  * Ensures that the filter follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array('abc123' => '123', 'abc 123' => '123', 'abcxyz' => '', 'AZ@#4.3' => '43');
     foreach ($valuesExpected as $input => $output) {
         $this->assertEquals($output, $this->_filter->filter($input));
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:DigitsTest.php

示例3: testBasic

 /**
  * Ensures that the filter follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array('abc123' => '123', 'abc 123' => '123', 'abcxyz' => '', 'AZ@#4.3' => '43', '1.23' => '123', '0x9f' => '09');
     foreach ($valuesExpected as $input => $output) {
         $this->assertEquals($output, $result = $this->_filter->filter($input), "Expected '{$input}' to filter to '{$output}', but received '{$result}' instead");
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:DigitsTest.php

示例4: isValid

    /**
     * Defined by Zend_Validate_Interface
     *
     * Returns true if and only if $value only contains digit characters
     *
     * @param  string $value
     * @return boolean
     */
    public function isValid($value)
    {
        if (!is_string($value) && !is_int($value) && !is_float($value)) {
            $this->_error(self::INVALID);
            return false;
        }

        $this->_setValue((string) $value);

        if ('' === $this->_value) {
            $this->_error(self::STRING_EMPTY);
            return false;
        }

        if (null === self::$_filter) {
            require_once 'Zend/Filter/Digits.php';
            self::$_filter = new Zend_Filter_Digits();
        }

        if ($this->_value !== self::$_filter->filter($this->_value)) {
            $this->_error(self::NOT_DIGITS);
            return false;
        }

        return true;
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:34,代码来源:Digits.php

示例5: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if $value follows the Luhn algorithm (mod-10 checksum)
  *
  * @param  string $value
  * @return boolean
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     if (null === self::$_filter) {
         /**
          * @see Zend_Filter_Digits
          */
         // require_once 'Zend/Filter/Digits.php';
         self::$_filter = new Zend_Filter_Digits();
     }
     $valueFiltered = self::$_filter->filter($value);
     $length = strlen($valueFiltered);
     if ($length < 13 || $length > 19) {
         $this->_error(self::LENGTH);
         return false;
     }
     $sum = 0;
     $weight = 2;
     for ($i = $length - 2; $i >= 0; $i--) {
         $digit = $weight * $valueFiltered[$i];
         $sum += floor($digit / 10) + $digit % 10;
         $weight = $weight % 2 + 1;
     }
     if ((10 - $sum % 10) % 10 != $valueFiltered[$length - 1]) {
         $this->_error(self::CHECKSUM, $valueFiltered);
         return false;
     }
     return true;
 }
开发者ID:ngchie,项目名称:system,代码行数:37,代码来源:Ccnum.php

示例6: filter

 public function filter($value)
 {
     $amount = explode('.', $value);
     if ($amount[0]) {
         $filter = new Zend_Filter_Digits();
         $filteredAmount = $filter->filter($amount[0]);
     }
     if ($amount[1]) {
         $filteredDecimals = $filter->filter($amount[1]);
         $filteredAmount = $filteredAmount . "." . $filteredDecimals;
         $filteredAmount = round((double) $filteredAmount, 2);
     }
     return $filteredAmount;
     //return number_format((float)$filteredAmount, 2, '.', '');;
 }
开发者ID:relyd,项目名称:aidstream,代码行数:15,代码来源:Currency.php

示例7: numerosAction

 public function numerosAction()
 {
     $v = new Zend_Filter_Digits();
     $numero = '123oi321';
     echo $v->filter($numero);
     exit;
 }
开发者ID:JoaoAntonioMaruti,项目名称:AulasUnipar2015,代码行数:7,代码来源:FiltroController.php

示例8: indexAction

 function indexAction()
 {
     //Zend_Session::namespaceUnset('cart');
     $yourCart = new Zend_Session_Namespace('cart');
     //$yourCart->count= ham_1($yourCart->count);
     $ssInfo = $yourCart->getIterator();
     $filter = new Zend_Filter_Digits();
     $id = $filter->filter($this->_arrParam['id']);
     if (count($yourCart->cart) == 0) {
         $cart[$id] = 1;
         $yourCart->cart = $cart;
     } else {
         //echo '<br>Trong gio hang da co san pham';
         $tmp = $ssInfo['cart'];
         if (array_key_exists($id, $tmp) == true) {
             $tmp[$id] = $tmp[$id] + 1;
         } else {
             $tmp[$id] = 1;
         }
         $yourCart->cart = $tmp;
     }
     $base = new Zend_View();
     $link = $base->baseUrl();
     $url = $link . "/shoppingcart";
     chuyen_trang($url);
 }
开发者ID:lynguyetvan88,项目名称:webtuthien,代码行数:26,代码来源:CartController.php

示例9: filter

 /**
  * Returns the result of filtering $value
  *
  * @param  mixed $value
  * @throws \Zend_Filter_Exception If filtering $value is impossible
  * @return mixed
  */
 public function filter($value)
 {
     $newValue = parent::filter($value);
     if (intval($newValue)) {
         return str_pad($newValue, 9, '0', STR_PAD_LEFT);
     }
     // Return as is when e.g. ********* or nothing
     return $value;
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:16,代码来源:Burgerservicenummer.php

示例10: isValid

 public function isValid($value)
 {
     if (!is_string($value) && !is_int($value) && !is_float($value)) {
         $this->_error(self::INVALID);
         return false;
     }
     $this->_setValue((string) $value);
     if ('' === $this->_value) {
         $this->_error(self::STRING_EMPTY);
         return false;
     }
     if (null === self::$_filter) {
         self::$_filter = new \Life\Filter\Digits();
     }
     if ($this->_value !== self::$_filter->filter($this->_value)) {
         $this->_error(self::NOT_DIGITS);
         return false;
     }
     return true;
 }
开发者ID:brgomes,项目名称:life-framework,代码行数:20,代码来源:Digits.php

示例11: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if $value only contains digit characters
  *
  * @param  string $value
  * @return boolean
  */
 public function isValid($value)
 {
     $valueString = (string) $value;
     $this->_setValue($valueString);
     if ('' === $valueString) {
         $this->_error(self::STRING_EMPTY);
         return false;
     }
     if (null === self::$_filter) {
         /**
          * @see Zend_Filter_Digits
          */
         require_once 'Zend/Filter/Digits.php';
         self::$_filter = new Zend_Filter_Digits();
     }
     if ($valueString !== self::$_filter->filter($valueString)) {
         $this->_error(self::NOT_DIGITS);
         return false;
     }
     return true;
 }
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:29,代码来源:Digits.php

示例12: testBasic

 /**
  * Ensures that the filter follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     if (self::$_unicodeEnabled && extension_loaded('mbstring')) {
         // Filter for the value with mbstring
         /**
          * The first element of $valuesExpected contains multibyte digit characters.
          *   But , Zend_Filter_Digits is expected to return only singlebyte digits.
          *
          * The second contains multibyte or singebyte space, and also alphabet.
          * The third  contains various multibyte characters.
          * The last contains only singlebyte digits.
          */
         $valuesExpected = array('192八3四8' => '123', 'C 4.5B 6' => '456', '9壱8@7.6,5#4' => '987654', '789' => '789');
     } else {
         // POSIX named classes are not supported, use alternative 0-9 match
         // Or filter for the value without mbstring
         $valuesExpected = array('abc123' => '123', 'abc 123' => '123', 'abcxyz' => '', 'AZ@#4.3' => '43', '1.23' => '123', '0x9f' => '09');
     }
     foreach ($valuesExpected as $input => $output) {
         $this->assertEquals($output, $result = $this->_filter->filter($input), "Expected '{$input}' to filter to '{$output}', but received '{$result}' instead");
     }
 }
开发者ID:omusico,项目名称:logica,代码行数:27,代码来源:DigitsTest.php

示例13: aprovarUsuario

 private function aprovarUsuario()
 {
     // Atualiza Cadastro
     $iId = $this->_getParam('id');
     $oCadastro = Administrativo_Model_Cadastro::getById($iId);
     $oCadastro->setStatus('1');
     $oCadastro->persist();
     $oFilterDigits = new Zend_Filter_Digits();
     $oFilterTrim = new Zend_Filter_StringTrim();
     // Cadastra Usuario
     $aDados = $this->_getAllParams();
     $aUsuario['id_perfil'] = $oFilterDigits->filter($aDados['id_perfil']);
     $aUsuario['tipo'] = $oFilterDigits->filter($aDados['tipo']);
     $aUsuario['cnpj'] = $oFilterDigits->filter($aDados['cpfcnpj']);
     $aUsuario['login'] = $oFilterTrim->filter($aDados['login']);
     $aUsuario['senha'] = $oFilterTrim->filter($aDados['senha']);
     $aUsuario['nome'] = $oFilterTrim->filter($aDados['nome']);
     $aUsuario['email'] = $oFilterTrim->filter($aDados['email']);
     $aUsuario['fone'] = $oFilterDigits->filter($aDados['telefone']);
     $oUsuario = new Administrativo_Model_Usuario();
     $oUsuario->persist($aUsuario);
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:22,代码来源:CadastroController.php

示例14: ContentFile

    /**
     * Helper main function
     * @param $actionsHtml String HTML code showing the action buttons
     * @param $content String The content of this element
     * @param $dbId Int DB id of the object
     * @param $order Int order of this item in the DB
     * @param $params Array parameters (if any)
     * @return String HTML to be inserted in the view
     */
    public function ContentFile($actionsHtml = '', $content = '', $dbId = 0, $order = 0, $params = array('level' => 1), $moduleName = 'adminpages', $pagstructureId = 0, $sharedInIds = '')
    {
        $eventsInfo = SafactivitylogOp::getAuthorNLastEditorForContent($dbId, $moduleName);
        $module = 'publicms';
        $params2 = array('mode' => 'filids', 'layout' => 'none', 'viewl' => 'list', 'noviewswitch' => 'Y', 'ids' => $content);
        $this->view->flist = array();
        $sql = '';
        $fltr = new Zend_Filter_Digits();
        if ($params2['mode'] == 'filids' && isset($params2['ids'])) {
            $ids = array();
            foreach (explode(',', $params2['ids']) as $id) {
                $ids[] = $fltr->filter($id);
            }
        }
        if (is_array($params) && isset($params['type']) && $params['type'] == "categories") {
            // Load the files id based on their category
            $linkedFiles = new FilfoldersFilfiles();
            $ids = array();
            foreach (preg_split('/,/', $content) as $category) {
                $ids[] = $linkedFiles->getFilfilesLinkedTo($category);
            }
        }
        $this->view->viewl = 'list';
        $this->view->noviewswitch = 'Y';
        $oFile = new Filfiles();
        $params2['flist'] = $oFile->getFileInfosByIdList($ids);
        $toret = '<li
                    class="' . $params['addClass'] . ' sydney_editor_li"
                    dbparams="' . $content . '"
                    type=""
                    editclass="files"
                    dbid="' . $dbId . '"
                    dborder="' . $order . '"
                    data-content-type="file-block"
                    pagstructureid="' . $pagstructureId . '"
                    sharedinids="' . $sharedInIds . '">
		' . $actionsHtml . '
			<div class="content">
				' . $this->view->partial('file/filelist.phtml', $module, $params2) . '
			</div>
			<p class="lastUpdatedContent sydney_editor_p">' . $eventsInfo['firstEvent'] . '<br />' . $eventsInfo['lastEvent'] . '</p>
		</li>';
        return $toret;
    }
开发者ID:Cryde,项目名称:sydney-core,代码行数:53,代码来源:ContentFile.php

示例15: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if $value follows the Luhn algorithm (mod-10 checksum)
  *
  * @param  string $value
  * @return boolean
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     $filterDigits = new Zend_Filter_Digits();
     $valueFiltered = $filterDigits->filter($value);
     $length = strlen($valueFiltered);
     if ($length < 13 || $length > 19) {
         $this->_error(self::LENGTH);
         return false;
     }
     $sum = 0;
     $weight = 2;
     for ($i = $length - 2; $i >= 0; $i--) {
         $digit = $weight * $valueFiltered[$i];
         $sum += floor($digit / 10) + $digit % 10;
         $weight = $weight % 2 + 1;
     }
     if ((10 - $sum % 10) % 10 != $valueFiltered[$length - 1]) {
         $this->_error(self::CHECKSUM, $valueFiltered);
         return false;
     }
     return true;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:31,代码来源:Ccnum.php


注:本文中的Zend_Filter_Digits::filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。