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


PHP is_integer函数代码示例

本文整理汇总了PHP中is_integer函数的典型用法代码示例。如果您正苦于以下问题:PHP is_integer函数的具体用法?PHP is_integer怎么用?PHP is_integer使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: seek_log_object

 /**
  * Get log object based on creation time and creator of the object
  *
  * @return midgardmvc_helper_location_log
  */
 function seek_log_object($person = null, $time = null)
 {
     if (is_integer($person) || is_string($person)) {
         $person_guid = $person;
     } elseif (is_null($person)) {
         $person_guid = $this->object->metadata->creator;
         // TODO: Use metadata.authors?
     } else {
         $person_guid = $person->guid;
     }
     if (is_null($time)) {
         $time = $this->object->metadata->published;
     }
     $person = new midgard_person($person_guid);
     $qb = midgardmvc_helper_location_log::new_query_builder();
     $qb->add_constraint('person', '=', $person->id);
     $qb->add_constraint('date', '<=', $time);
     $qb->add_order('date', 'DESC');
     $qb->set_limit(1);
     $matches = $qb->execute();
     if (count($matches) > 0) {
         return $matches[0];
     }
     return null;
 }
开发者ID:bergie,项目名称:midgardmvc_helper_location,代码行数:30,代码来源:object.php

示例2: addFilter

 /**
  * Add a filter specific to this writer.
  * 
  * @param  Zend_Log_Filter_Interface  $filter
  * @return void
  */
 public function addFilter($filter)
 {
     if (is_integer($filter)) {
         $filter = new Zend_Log_Filter_Priority($filter);
     }
     $this->_filters[] = $filter;
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:13,代码来源:Abstract.php

示例3: create

 /**
  * Create destination object
  *
  * @param Zend_Pdf_Page|integer $page  Page object or page number
  * @param float $left  Left edge of displayed page
  * @param float $top   Top edge of displayed page
  * @param float $zoom  Zoom factor
  * @return Zend_Pdf_Destination_Zoom
  * @throws Zend_Pdf_Exception
  */
 public static function create($page, $left = null, $top = null, $zoom = null)
 {
     $destinationArray = new Zend_Pdf_Element_Array();
     if ($page instanceof Zend_Pdf_Page) {
         $destinationArray->items[] = $page->getPageDictionary();
     } else {
         if (is_integer($page)) {
             $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
         } else {
             require_once 'Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
         }
     }
     $destinationArray->items[] = new Zend_Pdf_Element_Name('XYZ');
     if ($left === null) {
         $destinationArray->items[] = new Zend_Pdf_Element_Null();
     } else {
         $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
     }
     if ($top === null) {
         $destinationArray->items[] = new Zend_Pdf_Element_Null();
     } else {
         $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
     }
     if ($zoom === null) {
         $destinationArray->items[] = new Zend_Pdf_Element_Null();
     } else {
         $destinationArray->items[] = new Zend_Pdf_Element_Numeric($zoom);
     }
     return new Zend_Pdf_Destination_Zoom($destinationArray);
 }
开发者ID:basdog22,项目名称:Qool,代码行数:41,代码来源:Zoom.php

示例4: addError

 /**
  * Adds an error.
  *
  * This method merges sfValidatorErrorSchema errors with the current instance.
  *
  * @param sfValidatorError $error  An sfValidatorError instance
  * @param string           $name   The error name
  */
 public function addError(sfValidatorError $error, $name = null)
 {
     if (is_null($name) || is_integer($name)) {
         if ($error instanceof sfValidatorErrorSchema) {
             $this->addErrors($error);
         } else {
             $this->globalErrors[] = $error;
             $this->errors[] = $error;
         }
     } else {
         if (!isset($this->namedErrors[$name]) && !$error instanceof sfValidatorErrorSchema) {
             $this->namedErrors[$name] = $error;
             $this->errors[$name] = $error;
         } else {
             if (!isset($this->namedErrors[$name])) {
                 $this->namedErrors[$name] = new sfValidatorErrorSchema($error->getValidator());
                 $this->errors[$name] = new sfValidatorErrorSchema($error->getValidator());
             } else {
                 if (!$this->namedErrors[$name] instanceof sfValidatorErrorSchema) {
                     $current = $this->namedErrors[$name];
                     $this->namedErrors[$name] = new sfValidatorErrorSchema($current->getValidator());
                     $this->errors[$name] = new sfValidatorErrorSchema($current->getValidator());
                     $method = $current instanceof sfValidatorErrorSchema ? 'addErrors' : 'addError';
                     $this->namedErrors[$name]->{$method}($current);
                     $this->errors[$name]->{$method}($current);
                 }
             }
             $method = $error instanceof sfValidatorErrorSchema ? 'addErrors' : 'addError';
             $this->namedErrors[$name]->{$method}($error);
             $this->errors[$name]->{$method}($error);
         }
     }
     $this->updateCode();
     $this->updateMessage();
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:43,代码来源:sfValidatorErrorSchema.class.php

示例5: onStartCacheSet

 function onStartCacheSet(&$key, &$value, &$flag, &$expiry, &$success)
 {
     if (empty($value)) {
         if (is_array($value)) {
             $this->log(LOG_INFO, "Setting empty array for key '{$key}'");
         } else {
             if (is_null($value)) {
                 $this->log(LOG_INFO, "Setting null value for key '{$key}'");
             } else {
                 if (is_string($value)) {
                     $this->log(LOG_INFO, "Setting empty string for key '{$key}'");
                 } else {
                     if (is_integer($value)) {
                         $this->log(LOG_INFO, "Setting integer 0 for key '{$key}'");
                     } else {
                         $this->log(LOG_INFO, "Setting empty value '{$value}' for key '{$key}'");
                     }
                 }
             }
         }
     } else {
         $this->log(LOG_INFO, "Setting non-empty value for key '{$key}'");
     }
     return true;
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:25,代码来源:CacheLogPlugin.php

示例6: getProperties

 protected function getProperties($object)
 {
     $reflClass = new \ReflectionClass($object);
     $codeAnnotation = $this->annotationReader->getClassAnnotation($reflClass, Segment::class);
     if (!$codeAnnotation) {
         throw new AnnotationMissing(sprintf("Missing @Segment annotation for class %", $reflClass->getName()));
     }
     $properties = [$codeAnnotation->value];
     foreach ($reflClass->getProperties() as $propRefl) {
         $propRefl->setAccessible(true);
         /** @var SegmentPiece $isSegmentPiece */
         $isSegmentPiece = $this->annotationReader->getPropertyAnnotation($propRefl, SegmentPiece::class);
         if ($isSegmentPiece) {
             if (!$isSegmentPiece->parts) {
                 $properties[$isSegmentPiece->position] = $propRefl->getValue($object);
             } else {
                 $parts = $isSegmentPiece->parts;
                 $value = $propRefl->getValue($object);
                 $valuePieces = [];
                 foreach ($parts as $key => $part) {
                     if (is_integer($key)) {
                         $partName = $part;
                     } else {
                         $partName = $key;
                     }
                     $valuePieces[] = isset($value[$partName]) ? $value[$partName] : null;
                 }
                 $properties[$isSegmentPiece->position] = $this->weedOutEmpty($valuePieces);
             }
         }
     }
     $properties = $this->weedOutEmpty($properties);
     return $properties;
 }
开发者ID:progrupa,项目名称:edifact,代码行数:34,代码来源:AnnotationPrinter.php

示例7: create

 /**
  * Create destination object
  *
  * @param \Zend\Pdf\Page|integer $page  Page object or page number
  * @param float $left  Left edge of displayed page
  * @param float $top   Top edge of displayed page
  * @param float $zoom  Zoom factor
  * @return \Zend\Pdf\Destination\Zoom
  * @throws \Zend\Pdf\Exception\ExceptionInterface
  */
 public static function create($page, $left = null, $top = null, $zoom = null)
 {
     $destinationArray = new InternalType\ArrayObject();
     if ($page instanceof Pdf\Page) {
         $destinationArray->items[] = $page->getPageDictionary();
     } elseif (is_integer($page)) {
         $destinationArray->items[] = new InternalType\NumericObject($page);
     } else {
         throw new Exception\InvalidArgumentException('$page parametr must be a \\Zend\\Pdf\\Page object or a page number.');
     }
     $destinationArray->items[] = new InternalType\NameObject('XYZ');
     if ($left === null) {
         $destinationArray->items[] = new InternalType\NullObject();
     } else {
         $destinationArray->items[] = new InternalType\NumericObject($left);
     }
     if ($top === null) {
         $destinationArray->items[] = new InternalType\NullObject();
     } else {
         $destinationArray->items[] = new InternalType\NumericObject($top);
     }
     if ($zoom === null) {
         $destinationArray->items[] = new InternalType\NullObject();
     } else {
         $destinationArray->items[] = new InternalType\NumericObject($zoom);
     }
     return new self($destinationArray);
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:38,代码来源:Zoom.php

示例8: __construct

    /**
     * Object constructor
     *
     * @param Zend_Pdf_Element $val
     * @param integer $objNum
     * @param integer $genNum
     * @param Zend_Pdf_ElementFactory $factory
     * @throws Zend_Pdf_Exception
     */
    public function __construct(Zend_Pdf_Element $val, $objNum, $genNum, Zend_Pdf_ElementFactory $factory)
    {
        if ($val instanceof self) {
            require_once 'Zend/Pdf/Exception.php';
            throw new Zend_Pdf_Exception('Object number must not be an instance of Zend_Pdf_Element_Object.');
        }

        if ( !(is_integer($objNum) && $objNum > 0) ) {
            require_once 'Zend/Pdf/Exception.php';
            throw new Zend_Pdf_Exception('Object number must be positive integer.');
        }

        if ( !(is_integer($genNum) && $genNum >= 0) ) {
            require_once 'Zend/Pdf/Exception.php';
            throw new Zend_Pdf_Exception('Generation number must be non-negative integer.');
        }

        $this->_value   = $val;
        $this->_objNum  = $objNum;
        $this->_genNum  = $genNum;
        $this->_factory = $factory;

        $this->setParentObject($this);

        $factory->registerObject($this, $objNum . ' ' . $genNum);
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:35,代码来源:Object.php

示例9: stringify

 /**
  * Stringifies any provided value.
  *
  * @param mixed $value        	
  * @param boolean $exportObject        	
  *
  * @return string
  */
 public function stringify($value, $exportObject = true)
 {
     if (is_array($value)) {
         if (range(0, count($value) - 1) === array_keys($value)) {
             return '[' . implode(', ', array_map(array($this, __FUNCTION__), $value)) . ']';
         }
         $stringify = array($this, __FUNCTION__);
         return '[' . implode(', ', array_map(function ($item, $key) use($stringify) {
             return (is_integer($key) ? $key : '"' . $key . '"') . ' => ' . call_user_func($stringify, $item);
         }, $value, array_keys($value))) . ']';
     }
     if (is_resource($value)) {
         return get_resource_type($value) . ':' . $value;
     }
     if (is_object($value)) {
         return $exportObject ? ExportUtil::export($value) : sprintf('%s:%s', get_class($value), spl_object_hash($value));
     }
     if (true === $value || false === $value) {
         return $value ? 'true' : 'false';
     }
     if (is_string($value)) {
         $str = sprintf('"%s"', str_replace("\n", '\\n', $value));
         if (50 <= strlen($str)) {
             return substr($str, 0, 50) . '"...';
         }
         return $str;
     }
     if (null === $value) {
         return 'null';
     }
     return (string) $value;
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:40,代码来源:StringUtil.php

示例10: isValid

 /**
  * Validate the error code, and if applicable, return an Exception to be thrown.
  * @return
  *   \OhUpload\Validate\Exception\UnknownInvalidErrorCodeException
  *   \OhUpload\Validate\Exception\MaximumFileSizeExceededException
  *   \OhUpload\Validate\Exception\NoFileUploadedException
  *   \OhUpload\Validate\Exception\TmpFolderMissingException
  *   \OhUpload\Validate\Exception\FailedToWriteToDiskException
  *   \OhUpload\Validate\Exception\ExtensionStoppedUploadException
  *   boolean true
  */
 public function isValid()
 {
     $code = @$this->file['error'];
     if (!is_integer($code)) {
         return new UnknownInvalidErrorCodeException('Upload error code was not an integer. Got "' . gettype($code) . '"');
     }
     switch ($code) {
         case 0:
             return true;
         case 1:
             return new MaximumFileSizeExceededException('The uploaded file exceeds the upload_max_filesize directive in php.ini.');
             break;
         case 2:
             return new MaximumFileSizeExceededException('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.');
             break;
         case 4:
             return new NoFileUploadedException('No file was uploaded.');
             break;
         case 6:
             return new TmpFolderMissingException('Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.');
             break;
         case 7:
             return new FailedToWriteToDiskException('Failed to write file to disk. Introduced in PHP 5.1.0.');
             break;
         case 8:
             return new ExtensionStoppedUploadException('A PHP extension stopped the file upload. PHP does not provide a way to ascertain which ' . 'extension caused the file upload to stop; examining the list of loaded extensions with ' . 'phpinfo() may help. Introduced in PHP 5.2.0.');
             break;
         default:
             break;
     }
     return new UnknownInvalidErrorCodeException('Unhandled error code detected. Received: "' . $code . '"');
 }
开发者ID:rogerthomas84,项目名称:ohupload,代码行数:43,代码来源:ErrorCode.php

示例11: wppb_changeDefaultAvatar

function wppb_changeDefaultAvatar($avatar, $id_or_email, $size, $default, $alt)
{
    global $wpdb;
    /* Get user info. */
    if (is_object($id_or_email)) {
        $my_user_id = $id_or_email->user_id;
    } elseif (is_numeric($id_or_email)) {
        $my_user_id = $id_or_email;
    } elseif (!is_integer($id_or_email)) {
        $user_info = get_user_by_email($id_or_email);
        $my_user_id = $user_info->ID;
    } else {
        $my_user_id = $id_or_email;
    }
    $arraySettingsPresent = get_option('wppb_custom_fields', 'not_found');
    if ($arraySettingsPresent != 'not_found') {
        $wppbFetchArray = get_option('wppb_custom_fields');
        foreach ($wppbFetchArray as $value) {
            if ($value['item_type'] == 'avatar') {
                $customUserAvatar = get_user_meta($my_user_id, 'resized_avatar_' . $value['id'], true);
                if ($customUserAvatar != '' || $customUserAvatar != null) {
                    $avatar = "<img alt='{$alt}' src='{$customUserAvatar}' class='avatar avatar-{$value['item_options']} photo avatar-default' height='{$size}' width='{$size}' />";
                }
            }
        }
    }
    return $avatar;
}
开发者ID:serker72,项目名称:T3S,代码行数:28,代码来源:premium.functions.load.php

示例12: calculatePagingHeaders

 /**
  * Calculate the link meta-data for paging purposes, return an array with paging information
  *
  * @param integer $limit
  * @param integer $offset
  * @param integer $total_rows The total amount of objects
  *
  * @return array
  */
 public static function calculatePagingHeaders($limit, $offset, $total_rows)
 {
     $paging = array();
     // Check if limit and offset are integers
     if (!is_integer((int) $limit) || !is_integer((int) $offset)) {
         \App::abort(400, "Please make sure limit and offset are integers.");
     }
     // Calculate the paging parameters and pass them with the data object
     if ($offset + $limit < $total_rows) {
         $paging['next'] = array($limit + $offset, $limit);
         $last_page = round($total_rows / $limit, 1);
         $last_full_page = round($total_rows / $limit, 0);
         if ($last_page - $last_full_page > 0) {
             $paging['last'] = array($last_full_page * $limit, $limit);
         } else {
             $paging['last'] = array(($last_full_page - 1) * $limit, $limit);
         }
     }
     if ($offset > 0 && $total_rows > 0) {
         $previous = $offset - $limit;
         if ($previous < 0) {
             $previous = 0;
         }
         $paging['previous'] = array($previous, $limit);
     }
     return $paging;
 }
开发者ID:jalbertbowden,项目名称:core,代码行数:36,代码来源:Pager.php

示例13: _conversationReply

 /**
  * A user has replied to a conversation.
  *
  * @param \Cake\Event\Event $event The event that was fired.
  *
  * @return bool
  */
 protected function _conversationReply(Event $event)
 {
     if (!is_integer($event->data['conversation_id'])) {
         return false;
     }
     $this->Conversations = TableRegistry::get('Conversations');
     $this->Users = TableRegistry::get('Users');
     $conversation = $this->Conversations->find()->where(['Conversations.id' => $event->data['conversation_id']])->select(['id', 'user_id', 'title', 'last_message_id'])->first();
     $sender = $this->Users->find('medium')->where(['Users.id' => $event->data['sender_id']])->first();
     //Check if this user hasn't already a notification. (Prevent for spam)
     $hasReplied = $this->Notifications->find()->where(['Notifications.foreign_key' => $conversation->id, 'Notifications.type' => $event->data['type'], 'Notifications.user_id' => $event->data['participant']->user->id])->first();
     if (!is_null($hasReplied)) {
         $hasReplied->data = serialize(['sender' => $sender, 'conversation' => $conversation]);
         $hasReplied->is_read = 0;
         $this->Notifications->save($hasReplied);
     } else {
         $data = [];
         $data['user_id'] = $event->data['participant']->user->id;
         $data['type'] = $event->data['type'];
         $data['data'] = serialize(['sender' => $sender, 'conversation' => $conversation]);
         $data['foreign_key'] = $conversation->id;
         $entity = $this->Notifications->newEntity($data);
         $this->Notifications->save($entity);
     }
     return true;
 }
开发者ID:Xety,项目名称:Xeta,代码行数:33,代码来源:Notifications.php

示例14: getHash

 /**
  * Generate a [salted] hash.
  *
  * $salt can be:
  * false - a random will be generated
  * integer - a random with specified length will be generated
  * string
  *
  * @param string $password
  * @param mixed $salt
  * @return string
  */
 public function getHash($password, $salt = false)
 {
     if (is_integer($salt)) {
         $salt = $this->_helper->getRandomString($salt);
     }
     return $salt === false ? $this->hash($password) : $this->hash($salt . $password) . ':' . $salt;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:19,代码来源:Encryption.php

示例15: testMuxGetId

 public function testMuxGetId()
 {
     $mux = new \Pux\Mux();
     $id = $mux->getId();
     ok(is_integer($id));
     is($id, $mux->getId());
 }
开发者ID:magicdice,项目名称:Pux,代码行数:7,代码来源:MuxTest.php


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