當前位置: 首頁>>代碼示例>>PHP>>正文


PHP is_numeric函數代碼示例

本文整理匯總了PHP中is_numeric函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_numeric函數的具體用法?PHP is_numeric怎麽用?PHP is_numeric使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了is_numeric函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: vc_dropdown_form_field

/**
 * Dropdown(select with options) shortcode attribute type generator.
 *
 * @param $settings
 * @param $value
 *
 * @since 4.4
 * @return string - html string.
 */
function vc_dropdown_form_field($settings, $value)
{
    $output = '';
    $css_option = str_replace('#', 'hash-', vc_get_dropdown_option($settings, $value));
    $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
    if (is_array($value)) {
        $value = isset($value['value']) ? $value['value'] : array_shift($value);
    }
    if (!empty($settings['value'])) {
        foreach ($settings['value'] as $index => $data) {
            if (is_numeric($index) && (is_string($data) || is_numeric($data))) {
                $option_label = $data;
                $option_value = $data;
            } elseif (is_numeric($index) && is_array($data)) {
                $option_label = isset($data['label']) ? $data['label'] : array_pop($data);
                $option_value = isset($data['value']) ? $data['value'] : array_pop($data);
            } else {
                $option_value = $data;
                $option_label = $index;
            }
            $selected = '';
            $option_value_string = (string) $option_value;
            $value_string = (string) $value;
            if ('' !== $value && $option_value_string === $value_string) {
                $selected = ' selected="selected"';
            }
            $option_class = str_replace('#', 'hash-', $option_value);
            $output .= '<option class="' . esc_attr($option_class) . '" value="' . esc_attr($option_value) . '"' . $selected . '>' . htmlspecialchars($option_label) . '</option>';
        }
    }
    $output .= '</select>';
    return $output;
}
開發者ID:severnrescue,項目名稱:web,代碼行數:42,代碼來源:default_params.php

示例2: saveDefaultFlags

 /**
  * Saves default_billing and default_shipping flags for customer address
  *
  * @param array $addressIdList
  * @param array $extractedCustomerData
  * @return array
  */
 protected function saveDefaultFlags(array $addressIdList, array &$extractedCustomerData)
 {
     $result = [];
     $extractedCustomerData[CustomerInterface::DEFAULT_BILLING] = null;
     $extractedCustomerData[CustomerInterface::DEFAULT_SHIPPING] = null;
     foreach ($addressIdList as $addressId) {
         $scope = sprintf('address/%s', $addressId);
         $addressData = $this->_extractData($this->getRequest(), 'adminhtml_customer_address', \Magento\Customer\Api\AddressMetadataInterface::ENTITY_TYPE_ADDRESS, ['default_billing', 'default_shipping'], $scope);
         if (is_numeric($addressId)) {
             $addressData['id'] = $addressId;
         }
         // Set default billing and shipping flags to customer
         if (!empty($addressData['default_billing']) && $addressData['default_billing'] === 'true') {
             $extractedCustomerData[CustomerInterface::DEFAULT_BILLING] = $addressId;
             $addressData['default_billing'] = true;
         } else {
             $addressData['default_billing'] = false;
         }
         if (!empty($addressData['default_shipping']) && $addressData['default_shipping'] === 'true') {
             $extractedCustomerData[CustomerInterface::DEFAULT_SHIPPING] = $addressId;
             $addressData['default_shipping'] = true;
         } else {
             $addressData['default_shipping'] = false;
         }
         $result[] = $addressData;
     }
     return $result;
 }
開發者ID:nblair,項目名稱:magescotch,代碼行數:35,代碼來源:Save.php

示例3: getEndpointFromFields

 /**
  * @param array $fields
  * @return array|null
  */
 public static function getEndpointFromFields(array $fields)
 {
     $arEndpointList = null;
     $fieldsTmp = array();
     foreach ($fields as $moduleId => $arConnectorSettings) {
         if (is_numeric($moduleId)) {
             $moduleId = '';
         }
         foreach ($arConnectorSettings as $connectorCode => $arConnectorFields) {
             foreach ($arConnectorFields as $k => $arFields) {
                 if (isset($fieldsTmp[$moduleId][$connectorCode][$k]) && is_array($arFields)) {
                     $fieldsTmp[$moduleId][$connectorCode][$k] = array_merge($fieldsTmp[$moduleId][$connectorCode][$k], $arFields);
                 } else {
                     $fieldsTmp[$moduleId][$connectorCode][$k] = $arFields;
                 }
             }
         }
     }
     foreach ($fieldsTmp as $moduleId => $arConnectorSettings) {
         if (is_numeric($moduleId)) {
             $moduleId = '';
         }
         foreach ($arConnectorSettings as $connectorCode => $arConnectorFields) {
             foreach ($arConnectorFields as $arFields) {
                 $arEndpoint = array();
                 $arEndpoint['MODULE_ID'] = $moduleId;
                 $arEndpoint['CODE'] = $connectorCode;
                 $arEndpoint['FIELDS'] = $arFields;
                 $arEndpointList[] = $arEndpoint;
             }
         }
     }
     return $arEndpointList;
 }
開發者ID:DarneoStudio,項目名稱:bitrix,代碼行數:38,代碼來源:connectormanager.php

示例4: parseSeries

 /**
  * Parses the arguments for ":nth-child()" and friends.
  *
  * @param Token[] $tokens
  *
  * @throws SyntaxErrorException
  *
  * @return array
  */
 public static function parseSeries(array $tokens)
 {
     foreach ($tokens as $token) {
         if ($token->isString()) {
             throw SyntaxErrorException::stringAsFunctionArgument();
         }
     }
     $joined = trim(implode('', array_map(function (Token $token) {
         return $token->getValue();
     }, $tokens)));
     $int = function ($string) {
         if (!is_numeric($string)) {
             throw SyntaxErrorException::stringAsFunctionArgument();
         }
         return (int) $string;
     };
     switch (true) {
         case 'odd' === $joined:
             return array(2, 1);
         case 'even' === $joined:
             return array(2, 0);
         case 'n' === $joined:
             return array(1, 0);
         case false === strpos($joined, 'n'):
             return array(0, $int($joined));
     }
     $split = explode('n', $joined);
     $first = isset($split[0]) ? $split[0] : null;
     return array($first ? '-' === $first || '+' === $first ? $int($first . '1') : $int($first) : 1, isset($split[1]) && $split[1] ? $int($split[1]) : 0);
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:39,代碼來源:Parser.php

示例5: remainingSerialsReport

 /**
  * @return ICC_Ecodes_Model_Downloadable
  */
 public function remainingSerialsReport()
 {
     /** added for log tracking by anil 28 jul **/
     $currDate = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
     $fileName = date("Y-m-d", Mage::getModel('core/date')->timestamp(time()));
     Mage::log("Controller Name : Ecode/Downloadable , Action Name : remainingSerialsReport , Start Time : {$currDate}", null, $fileName);
     /** end **/
     $threshold = Mage::getStoreConfig(self::XML_PATH_REPORT_THRESHOLD);
     $errors = array();
     if (!is_numeric($threshold) || $threshold < 0) {
         $error = "Threshold was not a positive integer.";
         $errors[] = $error;
         Mage::log("Error while attempting to run " . __METHOD__ . ". " . $error);
     } else {
         $notifications = $this->getCollection()->prepareForRemainingReport($threshold);
         if ($notifications->count()) {
             try {
                 $this->sendNotificationEmail($notifications);
             } catch (Exception $e) {
                 Mage::logException($e);
             }
         }
     }
     /** added for log tracking by anil 28 jul start **/
     $currDate = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
     Mage::log("Controller Name : Ecode/Downloadable , Action Name : remainingSerialsReport , End Time : {$currDate}", null, $fileName);
     /** end **/
     return $this;
 }
開發者ID:ankita-parashar,項目名稱:magento,代碼行數:32,代碼來源:ICC_Ecodes_Model_Downloadable.php

示例6: XMLAppend

 /**
  * Append any supported $content to $parent
  *
  * @param  DOMNode $parent  Node to append to
  * @param  mixed   $content Content to append
  * @return self
  */
 protected function XMLAppend(\DOMNode &$parent = null, $content = null)
 {
     if (is_null($parent)) {
         $parent = $this->root;
     }
     if (is_string($content) or is_numeric($content) or is_object($content) and method_exists($content, '__toString')) {
         $parent->appendChild($this->createTextNode("{$content}"));
     } elseif (is_object($content) and is_subclass_of($content, '\\DOMNode')) {
         $parent->appendChild($content);
     } elseif (is_array($content) or is_object($content) and $content = get_object_vars($content)) {
         array_map(function ($node, $value) use(&$parent) {
             if (is_string($node)) {
                 if (substr($node, 0, 1) === '@') {
                     $parent->setAttribute(substr($node, 1), $value);
                 } else {
                     $node = $parent->appendChild($this->createElement($node));
                     if (is_string($value)) {
                         $this->XMLAppend($node, $this->createTextNode($value));
                     } else {
                         $this->XMLAppend($node, $value);
                     }
                 }
             } else {
                 $this->XMLAppend($parent, $value);
             }
         }, array_keys($content), array_values($content));
     } elseif (is_bool($content)) {
         $parent->appendChild($this->createTextNode($content ? 'true' : 'false'));
     } else {
         throw new \InvalidArgumentException(sprintf('Unable to append unknown content [%s] to %s', get_class($content), get_class($this)));
     }
     return $this;
 }
開發者ID:KVSun,項目名稱:core_api,代碼行數:40,代碼來源:xmlappend.php

示例7: test_smarty_modifier_unique

 function test_smarty_modifier_unique()
 {
     //  配列でない場合
     $result = smarty_modifier_unique('a');
     $this->assertTrue('a', $result);
     $result = smarty_modifier_unique(NULL);
     $this->assertNULL($result);
     //  第2引數なしの場合
     $input = array(1, 2, 1, 1, 3, 2, 4);
     $result = smarty_modifier_unique($input);
     $this->assertTrue(is_numeric(array_search(1, $result)));
     $this->assertTrue(is_numeric(array_search(2, $result)));
     $this->assertTrue(is_numeric(array_search(3, $result)));
     $this->assertTrue(is_numeric(array_search(4, $result)));
     $this->assertFalse(is_numeric(array_search(5, $result)));
     //  第2引數ありの場合
     $input = array(array("foo" => 1, "bar" => 4), array("foo" => 1, "bar" => 4), array("foo" => 1, "bar" => 4), array("foo" => 2, "bar" => 5), array("foo" => 3, "bar" => 6), array("foo" => 2, "bar" => 5));
     $result = smarty_modifier_unique($input, 'bar');
     $this->assertTrue(is_numeric(array_search(4, $result)));
     $this->assertTrue(is_numeric(array_search(5, $result)));
     $this->assertTrue(is_numeric(array_search(6, $result)));
     $this->assertFalse(is_numeric(array_search(1, $result)));
     $this->assertFalse(is_numeric(array_search(2, $result)));
     $this->assertFalse(is_numeric(array_search(3, $result)));
 }
開發者ID:weiweiabc109,項目名稱:test_project1,代碼行數:25,代碼來源:Ethna_Plugin_Smarty_modifier_unique_Test.php

示例8: validates

 public function validates()
 {
     if (!isset($this->property_id) || !is_numeric($this->property_id)) {
         $this->addValError('Invalid property id');
     }
     $this->doValType(Validate::TEXT, 'option_val', $this->option_val, false);
 }
開發者ID:mikejw,項目名稱:elib-experimental,代碼行數:7,代碼來源:PropertyOption.php

示例9: validateAttribute

 /**
  * Validates the attribute of the object.
  * If there is any error, the error message is added to the object.
  *
  * @param \Model $object    the object being validated
  * @param string $attribute the attribute being validated
  */
 protected function validateAttribute($object, $attribute)
 {
     $value = $object->{$attribute};
     if ($this->allowEmpty && $this->isEmpty($value)) {
         return;
     }
     if (!is_numeric($value)) {
         // https://github.com/yiisoft/yii/issues/1955
         // https://github.com/yiisoft/yii/issues/1669
         $message = $this->message !== null ? $this->message : '{attribute} must be a number.';
         $this->addError($object, $attribute, $message);
         return;
     }
     if ($this->integerOnly) {
         if (!preg_match($this->integerPattern, "{$value}")) {
             $message = $this->message !== null ? $this->message : '{attribute} must be an integer.';
             $this->addError($object, $attribute, $message);
         }
     } else {
         if (!preg_match($this->numberPattern, "{$value}")) {
             $message = $this->message !== null ? $this->message : '{attribute} must be a number.';
             $this->addError($object, $attribute, $message);
         }
     }
     if ($this->min !== null && $value < $this->min) {
         $message = $this->tooSmall !== null ? $this->tooSmall : '{attribute} is too small (minimum is {min}).';
         $this->addError($object, $attribute, $message, ['{min}' => $this->min]);
     }
     if ($this->max !== null && $value > $this->max) {
         $message = $this->tooBig !== null ? $this->tooBig : '{attribute} is too big (maximum is {max}).';
         $this->addError($object, $attribute, $message, ['{max}' => $this->max]);
     }
 }
開發者ID:astar3086,項目名稱:studio_logistic,代碼行數:40,代碼來源:NumberValidator.php

示例10: maj_vieille_base_1927_create

function maj_vieille_base_1927_create() {
  global $tables_principales, $tables_auxiliaires, $tables_images, $tables_sequences, $tables_documents, $tables_mime;

	// ne pas revenir plusieurs fois (si, au contraire, il faut pouvoir
	// le faire car certaines mises a jour le demandent explicitement)
	# static $vu = false;
	# if ($vu) return; else $vu = true;

	foreach($tables_principales as $k => $v)
		spip_create_vieille_table($k, $v['field'], $v['key'], true);

	foreach($tables_auxiliaires as $k => $v)
		spip_create_vieille_table($k, $v['field'], $v['key'], false);

	foreach($tables_images as $k => $v)
		sql_query("INSERT IGNORE INTO spip_types_documents (extension, inclus, titre, id_type) VALUES ('$k', 'image', '" .
			      (is_numeric($v) ?
			       (strtoupper($k) . "', $v") :
			       "$v', 0") .
			      ")");

	foreach($tables_sequences as $k => $v)
		sql_query("INSERT IGNORE INTO spip_types_documents (extension, titre, inclus) VALUES ('$k', '$v', 'embed')");

	foreach($tables_documents as $k => $v)
		sql_query("INSERT IGNORE INTO spip_types_documents (extension, titre, inclus) VALUES ('$k', '$v', 'non')");

	foreach ($tables_mime as $extension => $type_mime)
	  sql_query("UPDATE spip_types_documents
		SET mime_type='$type_mime' WHERE extension='$extension'");
}
開發者ID:rhertzog,項目名稱:lcs,代碼行數:31,代碼來源:create.php

示例11: mdl_const

 function mdl_const($str_type)
 {
     if (!fn_token("chk")) {
         //令牌
         $this->obj_ajax->halt_alert("x030102");
     }
     $_arr_opt = fn_post("opt");
     $_str_content = "<?php" . PHP_EOL;
     foreach ($_arr_opt as $_key => $_value) {
         $_arr_optChk = validateStr($_value, 1, 900);
         $_str_optValue = $_arr_optChk["str"];
         if (is_numeric($_value)) {
             $_str_content .= "define(\"" . $_key . "\", " . $_str_optValue . ");" . PHP_EOL;
         } else {
             $_str_content .= "define(\"" . $_key . "\", \"" . str_replace(PHP_EOL, "|", $_str_optValue) . "\");" . PHP_EOL;
         }
     }
     if ($str_type == "base") {
         $_str_content .= "define(\"BG_SITE_SSIN\", \"" . fn_rand(6) . "\");" . PHP_EOL;
     } else {
         if ($str_type == "visit") {
             if ($_arr_opt["BG_VISIT_TYPE"] != "static") {
                 $_str_content .= "define(\"BG_VISIT_FILE\", \"html\");" . PHP_EOL;
             }
         }
     }
     $_str_content = str_replace("||", "", $_str_content);
     $_num_size = file_put_contents(BG_PATH_CONFIG . "opt_" . $str_type . ".inc.php", $_str_content);
     if ($_num_size > 0) {
         $_str_alert = "y060101";
     } else {
         $_str_alert = "x060101";
     }
     return array("alert" => $_str_alert);
 }
開發者ID:richardcj,項目名稱:baigoCMS,代碼行數:35,代碼來源:opt.class.php

示例12: array_to_xml

function array_to_xml($phpResponse, &$phpResponseToXML)
{
    foreach ($phpResponse as $key => $value) {
        if (is_array($value)) {
            if (!is_numeric($key)) {
                // For non-numeric keys, give name same as key to the node
                $subnode = $phpResponseToXML->addChild("{$key}");
                // Recursive call to the function since the value was an array
                array_to_xml($value, $subnode);
            } else {
                // For numeric keys, give a name to the node
                //$subnode = $phpResponseToXML->addChild("item$key");
                if (current($phpResponseToXML->xpath('parent::*'))) {
                    $subnode = $phpResponseToXML->addChild("Showing");
                } else {
                    $subnode = $phpResponseToXML->addChild("Show");
                }
                //Recursive call to the function since the value was an array
                array_to_xml($value, $subnode);
            }
        } else {
            // Save the node and its value in XMLFiles format
            //$phpResponseToXML->addChild("$key","$value");
            $phpResponseToXML->{$key} = $value;
        }
    }
}
開發者ID:CheukYuen,項目名稱:Ticketing_System_Cinequest,代碼行數:27,代碼來源:generateXML_EventsWithShowings.php

示例13: test_isNumericNotValid

 public function test_isNumericNotValid()
 {
     $notvalid = array('-1.0.0', '1,2', '--1', '-.', '- 1', '1-');
     foreach ($notvalid as $toTest) {
         $this->assertFalse(is_numeric($toTest), $toTest . " valid but shouldn't!");
     }
 }
開發者ID:nnnnathann,項目名稱:piwik,代碼行數:7,代碼來源:Piwik.test.php

示例14: execute

 /**
  * Check move quote item to wishlist request
  *
  * @param   Observer $observer
  * @return  $this
  */
 public function execute(Observer $observer)
 {
     $cart = $observer->getEvent()->getCart();
     $data = $observer->getEvent()->getInfo()->toArray();
     $productIds = [];
     $wishlist = $this->getWishlist($cart->getQuote()->getCustomerId());
     if (!$wishlist) {
         return $this;
     }
     /**
      * Collect product ids marked for move to wishlist
      */
     foreach ($data as $itemId => $itemInfo) {
         if (!empty($itemInfo['wishlist']) && ($item = $cart->getQuote()->getItemById($itemId))) {
             $productId = $item->getProductId();
             $buyRequest = $item->getBuyRequest();
             if (array_key_exists('qty', $itemInfo) && is_numeric($itemInfo['qty'])) {
                 $buyRequest->setQty($itemInfo['qty']);
             }
             $wishlist->addNewItem($productId, $buyRequest);
             $productIds[] = $productId;
             $cart->getQuote()->removeItem($itemId);
         }
     }
     if (count($productIds)) {
         $wishlist->save();
         $this->wishlistData->calculate();
     }
     return $this;
 }
開發者ID:IlyaGluschenko,項目名稱:protection,代碼行數:36,代碼來源:CartUpdateBefore.php

示例15: pledgeName

 /**
  * Function for building Pledge Name combo box
  */
 function pledgeName(&$config)
 {
     $getRecords = FALSE;
     if (isset($_GET['name']) && $_GET['name']) {
         $name = CRM_Utils_Type::escape($_GET['name'], 'String');
         $name = str_replace('*', '%', $name);
         $whereClause = "p.creator_pledge_desc LIKE '%{$name}%' ";
         $getRecords = TRUE;
     }
     if (isset($_GET['id']) && is_numeric($_GET['id'])) {
         $pledgeId = CRM_Utils_Type::escape($_GET['id'], 'Integer');
         $whereClause = "p.id = {$pledgeId} ";
         $getRecords = TRUE;
     }
     if ($getRecords) {
         $query = "\nSELECT p.creator_pledge_desc, p.id\nFROM civicrm_pb_pledge p\nWHERE {$whereClause}\n";
         $dao = CRM_Core_DAO::executeQuery($query);
         $elements = array();
         while ($dao->fetch()) {
             $elements[] = array('name' => $dao->creator_pledge_desc, 'value' => $dao->id);
         }
     }
     if (empty($elements)) {
         $name = $_GET['name'];
         if (!$name && isset($_GET['id'])) {
             $name = $_GET['id'];
         }
         $elements[] = array('name' => trim($name, '*'), 'value' => trim($name, '*'));
     }
     echo CRM_Utils_JSON::encode($elements, 'value');
     CRM_Utils_System::civiExit();
 }
開發者ID:peteainsworth,項目名稱:civicrm-4.2.9-drupal,代碼行數:35,代碼來源:AJAX.php


注:本文中的is_numeric函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。