本文整理汇总了PHP中is_int函数的典型用法代码示例。如果您正苦于以下问题:PHP is_int函数的具体用法?PHP is_int怎么用?PHP is_int使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: system_add_credentials
function system_add_credentials()
{
if (!isset($_POST['AddCredentials'])) {
$details = new stdClass();
$details->system_id = intval($this->uri->segment(3, 0));
if (!is_int($details->system_id) or $details->system_id == 0) {
redirect('main/list_devices');
}
$this->load->model("m_system");
$this->data['system_id'] = $details->system_id;
$this->data['ip_address'] = ip_address_from_db($this->m_system->check_man_ip_address($details->system_id));
$this->data['heading'] = 'Add Device SNMP Credentials';
$this->data['include'] = 'v_add_system_c';
$this->load->view('v_template', $this->data);
} else {
$system_id = $_POST['system_id'];
$this->load->model("m_system");
$this->load->library('encrypt');
if ($_POST['snmp_community'] > '' and $_POST['snmp_version'] > '' and $_POST['ip_address'] > '') {
$encode['ip_address'] = $_POST['ip_address'];
$encode['snmp_version'] = $_POST['snmp_version'];
$encode['snmp_community'] = $_POST['snmp_community'];
$encoded = json_encode($encode);
$encoded = $this->encrypt->encode($encoded);
$this->m_system->update_system_man($system_id, 'access_details', $encoded);
if ($_POST['snmp_scan'] == TRUE) {
redirect('admin_system/system_snmp/' . $system_id);
} else {
redirect('main/system_display/' . $system_id);
}
} else {
redirect('admin_system/system_add_credentials/' . $system_id);
}
}
}
示例2: setSelected
public function setSelected($value = 'yes')
{
if (is_string($value) && ($value == 'yes' || $value == 'selected' || $value == 'on') || is_int($value) && $value != 0) {
return $this->attributes['selected'] = 'selected';
}
$this->removeAttribute('selected');
}
示例3: addCommandsFromClass
public function addCommandsFromClass($className, $passThrough = null)
{
$roboTasks = new $className();
$commandNames = array_filter(get_class_methods($className), function ($m) {
return !in_array($m, ['__construct']);
});
foreach ($commandNames as $commandName) {
$command = $this->createCommand(new TaskInfo($className, $commandName));
$command->setCode(function (InputInterface $input) use($roboTasks, $commandName, $passThrough) {
// get passthru args
$args = $input->getArguments();
array_shift($args);
if ($passThrough) {
$args[key(array_slice($args, -1, 1, TRUE))] = $passThrough;
}
$args[] = $input->getOptions();
$res = call_user_func_array([$roboTasks, $commandName], $args);
if (is_int($res)) {
exit($res);
}
if (is_bool($res)) {
exit($res ? 0 : 1);
}
if ($res instanceof Result) {
exit($res->getExitCode());
}
});
$this->add($command);
}
}
示例4: index
public function index()
{
$this->load_language('product/manufacturer');
$this->load->model('catalog/manufacturer');
$this->load->model('tool/image');
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
$this->data['breadcrumbs'][] = array('text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer'), 'separator' => $this->language->get('text_separator'));
$this->data['categories'] = array();
$results = $this->model_catalog_manufacturer->getManufacturers();
foreach ($results as $result) {
if (is_int(substr($result['name'], 0, 1))) {
$key = '0 - 9';
} else {
$key = substr(strtoupper($this->getFirstLetter($result['name'])), 0, 1);
}
if (!isset($this->data['manufacturers'][$key])) {
$this->data['categories'][$key]['name'] = $key;
}
$this->data['categories'][$key]['manufacturer'][] = array('name' => $result['name'], 'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $result['manufacturer_id']));
}
sort($this->data['categories']);
$this->data['continue'] = $this->url->link('common/home');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/manufacturer_list.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/manufacturer_list.tpl';
} else {
$this->template = 'default/template/product/manufacturer_list.tpl';
}
$this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
$this->response->setOutput($this->render());
}
示例5: indexMetadataObjects
/**
* @param KalturaMetadataFilter $filter
* @param $shouldUpdate
* @return int
*/
protected function indexMetadataObjects(KalturaMetadataFilter $filter, $shouldUpdate)
{
$filter->orderBy = KalturaMetadataOrderBy::CREATED_AT_ASC;
$metadataPlugin = KalturaMetadataClientPlugin::get(KBatchBase::$kClient);
$metadataList = $metadataPlugin->metadata->listAction($filter, $this->pager);
if (!count($metadataList->objects)) {
return 0;
}
KBatchBase::$kClient->startMultiRequest();
foreach ($metadataList->objects as $metadata) {
$metadataPlugin->metadata->index($metadata->id, $shouldUpdate);
}
$results = KBatchBase::$kClient->doMultiRequest();
foreach ($results as $index => $result) {
if (!is_int($result)) {
unset($results[$index]);
}
}
if (!count($results)) {
return 0;
}
$lastIndexId = end($results);
$this->setLastIndexId($lastIndexId);
return count($results);
}
示例6: detach
public function detach(odObserver $observer)
{
if (is_int($key = array_search($observer, $this->__observers, true))) {
unset($this->__observers[$key]);
}
return $this;
}
示例7: setTimeout
public function setTimeout($seconds)
{
if (is_int($seconds)) {
$this->timeout = $seconds;
return true;
}
}
示例8: checkType
/**
* Returns `true` if value is of the specified type
*
* @param string $type
* @param mixed $value
* @return bool
*/
protected function checkType($type, $value)
{
switch ($type) {
case 'array':
return is_array($value);
case 'bool':
case 'boolean':
return is_bool($value);
case 'callable':
return is_callable($value);
case 'float':
case 'double':
return is_float($value);
case 'int':
case 'integer':
return is_int($value);
case 'null':
return is_null($value);
case 'numeric':
return is_numeric($value);
case 'object':
return is_object($value);
case 'resource':
return is_resource($value);
case 'scalar':
return is_scalar($value);
case 'string':
return is_string($value);
case 'mixed':
return true;
default:
return $value instanceof $type;
}
}
示例9: assertInteger
private function assertInteger($integer, $throwable = null)
{
$throwable = ThrowableUtilities::validateAndNormalizeThrowable($throwable, new Exception\InvalidArgumentException('Argument must be an integer'));
if (!is_int($integer)) {
throw $throwable;
}
}
示例10: generate_query_string
/**
* Generates, encodes, re-orders variables for the query string.
*
* @param array $params The specific parameters for this payment
* @param array $pairs Pairs
* @param string $namespace The namespace
*
* @return string An encoded string of parameters
*/
public static function generate_query_string($params, &$pairs = array(), $namespace = null)
{
if (is_array($params)) {
foreach ($params as $k => $v) {
if (is_int($k)) {
GoCardless_Utils::generate_query_string($v, $pairs, $namespace . '[]');
} else {
GoCardless_Utils::generate_query_string($v, $pairs, $namespace !== null ? $namespace . "[{$k}]" : $k);
}
}
if ($namespace !== null) {
return $pairs;
}
if (empty($pairs)) {
return '';
}
usort($pairs, array(__CLASS__, 'sortPairs'));
$strs = array();
foreach ($pairs as $pair) {
$strs[] = $pair[0] . '=' . $pair[1];
}
return implode('&', $strs);
} else {
$pairs[] = array(rawurlencode($namespace), rawurlencode($params));
}
}
示例11: setNbrPlanches
public function setNbrPlanches($nbrPlanches)
{
$nbrPlanches = (int) $nbrPlanches;
if (is_int($nbrPlanches) && $nbrPlanches >= 0) {
$this->_nbrPlanches = $nbrPlanches;
}
}
示例12: add
public static function add($class, $behaviors)
{
foreach ($behaviors as $name => $parameters) {
if (is_int($name)) {
// no parameters
$name = $parameters;
} else {
// register parameters
foreach ($parameters as $key => $value) {
sfConfig::set('propel_behavior_' . $name . '_' . $class . '_' . $key, $value);
}
}
if (!isset(self::$behaviors[$name])) {
throw new sfConfigurationException(sprintf('Propel behavior "%s" is not registered', $name));
}
// register hooks
foreach (self::$behaviors[$name]['hooks'] as $hook => $callables) {
foreach ($callables as $callable) {
sfMixer::register('Base' . $class . $hook, $callable);
}
}
// register new methods
foreach (self::$behaviors[$name]['methods'] as $callable) {
sfMixer::register('Base' . $class, $callable);
}
}
}
示例13: mf_validate_float
function mf_validate_float($value)
{
global $mf_lang;
$error_message = $mf_lang['val_float'];
$value = $value[0];
if (is_int($value)) {
return $error_message;
//it's integer
} else {
if (is_float($value)) {
return true;
//it's float
} else {
if (is_numeric($value)) {
$result = strpos($value, '.');
if ($result !== false) {
return true;
//it's float
} else {
return $error_message;
//it's integer
}
} else {
return $error_message;
//it's not even a number!
}
}
}
}
示例14: savedata
function savedata()
{
global $filesystem;
$top = '<?php' . "\nif (defined('VISCACHA_CORE') == false) { die('Error: Hacking Attempt'); }\n";
$top .= '$' . $this->varname . ' = array();' . "\n";
$cfg = array();
while (list($key, $val) = each($this->data)) {
if (is_array($val)) {
foreach ($val as $key2 => $val2) {
if (isset($this->opt[$key][$key2]) && $this->opt[$key][$key2] == int || is_int($val2)) {
$val2 = intval($val2);
} else {
$val2 = $this->_prepareString($val2);
}
$cfg[] = '$' . $this->varname . "['{$key}']['{$key2}'] = {$val2};";
}
} else {
if (isset($this->opt[$key]) && $this->opt[$key] == int || is_int($val)) {
$val = intval($val);
} else {
$val = $this->_prepareString($val);
}
$cfg[] = '$' . $this->varname . "['{$key}'] = {$val};";
}
}
natcasesort($cfg);
$newdata = implode("\n", $cfg);
$bottom = "\n" . '?>';
$filesystem->file_put_contents($this->file, $top . $newdata . $bottom);
}
示例15: send
/**
* Send data to realplexor.
* Throw Dklab_Realplexor_Exception in case of error.
*
* @param mixed $idsAndCursors Target IDs in form of: array(id1 => cursor1, id2 => cursor2, ...)
* of array(id1, id2, id3, ...). If sending to a single ID,
* you may pass it as a plain string, not array.
* @param mixed $data Data to be sent (any format, e.g. nested arrays are OK).
* @param array $showOnlyForIds Send this message to only those who also listen any of these IDs.
* This parameter may be used to limit the visibility to a closed
* number of cliens: give each client an unique ID and enumerate
* client IDs in $showOnlyForIds to not to send messages to others.
* @return void
*/
public function send($idsAndCursors, $data, $showOnlyForIds = null)
{
$data = json_encode($data);
$pairs = array();
foreach ((array) $idsAndCursors as $id => $cursor) {
if (is_int($id)) {
$id = $cursor;
// this is NOT cursor, but ID!
$cursor = null;
}
if (!preg_match('/^\\w+$/', $id)) {
throw new Dklab_Realplexor_Exception("Identifier must be alphanumeric, \"{$id}\" given");
}
$id = $this->_namespace . $id;
if ($cursor !== null) {
if (!is_numeric($cursor)) {
throw new Dklab_Realplexor_Exception("Cursor must be numeric, \"{$cursor}\" given");
}
$pairs[] = "{$cursor}:{$id}";
} else {
$pairs[] = $id;
}
}
if (is_array($showOnlyForIds)) {
foreach ($showOnlyForIds as $id) {
$pairs[] = "*" . $this->_namespace . $id;
}
}
$this->_send(join(",", $pairs), $data);
}