• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP is_number函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: connect

 /**
  * Open a connection to MySQL & Select DB
  *
  * @version     1.0
  * @since       1.0.0
  * @author      Dan Aldridge
  *
  * @param       array    $config
  *
  * @return      bool
  */
 public function connect()
 {
     // add check for port, and append it to the hostname
     if (isset($this->dbSettings['port']) && is_number($this->dbSettings['port'])) {
         $this->dbSettings['host'] .= ':' . $this->dbSettings['port'];
     }
     // if we have persistent enabled, we'll try that first
     if ($this->dbSettings['persistent'] === true) {
         $this->DBH = @mysql_pconnect($this->dbSettings['host'], $this->dbSettings['username'], $this->dbSettings['password']);
         if ($this->DBH === false) {
             $this->dbSettings['persistent'] = false;
         }
     }
     //persistent is off, lets try and connect normally
     if ($this->dbSettings['persistent'] === false) {
         $this->DBH = @mysql_connect($this->dbSettings['host'], $this->dbSettings['username'], $this->dbSettings['password']);
     }
     //we havent got a resource we need to bomb out now
     if ($this->DBH === false) {
         trigger_error('Cannot connect to the database - verify username and password.<br />', E_USER_ERROR);
         return false;
     }
     //select the DB
     if ($this->selectDB($this->dbSettings['database']) === false) {
         trigger_error('Cannot select database - check user permissions.<br />', E_USER_ERROR);
         return false;
     }
     $this->registerPrefix('#__', $this->dbSettings['prefix']);
     $this->query('SET CHARACTER SET utf8;');
     $this->query('SET GLOBAL innodb_flush_log_at_trx_commit = 2;');
     //and carry on
     return true;
 }
开发者ID:richard-clifford,项目名称:CSCMS,代码行数:44,代码来源:class.mysql.php


示例2: decode

	function decode($Type, $Key){
		if(is_number($Type)) { // Element is a string
			// Get length of string
			$StrLen = $Type;
			while($this->Str[$this->Pos+1]!=':'){
				$this->Pos++;
				$StrLen.=$this->Str[$this->Pos];
			}
			$this->Val[$Key] = substr($this->Str, $this->Pos+2, $StrLen);
			
			$this->Pos+=$StrLen;
			$this->Pos+=2;
			
		} elseif($Type == 'i') { // Element is an int
			$this->Pos++;
			
			// Find end of integer (first occurance of 'e' after position)
			$End = strpos($this->Str, 'e', $this->Pos); 
			
			// Get the integer, and - IMPORTANT - cast it as an int, so we know later that it's an int and not a string
			$this->Val[$Key] = (int)substr($this->Str, $this->Pos, $End-$this->Pos); 
			$this->Pos = $End+1;
			
		} elseif($Type == 'l') { // Element is a list
			$this->Val[$Key] = new BENCODE_LIST(substr($this->Str, $this->Pos));
			$this->Pos += $this->Val[$Key]->Pos;
		
		} elseif($Type == 'd') { // Element is a dictionary
			$this->Val[$Key] = new BENCODE_DICT(substr($this->Str, $this->Pos));
			$this->Pos += $this->Val[$Key]->Pos;
		
		} else {
			die('Invalid torrent file');
		}
	}
开发者ID:4play,项目名称:gazelle2,代码行数:35,代码来源:class_torrent.php


示例3: goodinput

function goodinput($string)
{
if(is_number($string))
{
$host="localhost"; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name="cryptum1_comments"; // Database name 

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
$q = "SELECT * FROM homepage WHERE postid = ".$string;
$resultb = mysql_query($q);
if ($resultb)
{
return true;
}
if (!$resultb)
{
return false;
}
}
else
{
return false;
}
}
开发者ID:visual000,项目名称:misc,代码行数:28,代码来源:post_comment_create.php


示例4: create_instance

 function create_instance()
 {
     // Include module lib
     $modlib = '../../mod/' . $this->module_name() . '/lib.php';
     if (file_exists($modlib)) {
         global $CFG;
         require_once $modlib;
     } else {
         return array(false, 'Module lib not found');
     }
     $ret = $this->set_module_instance_params();
     if (!$ret[0]) {
         return $ret;
     }
     // Add instance and update course_modules DB row
     $addinstancefunction = $this->module_name() . '_add_instance';
     if ($this->get_num_instance_function_params() == 1) {
         $returnfromfunc = $addinstancefunction($this->moduleobj);
     } else {
         $returnfromfunc = $addinstancefunction($this->moduleobj, true);
     }
     if (!$returnfromfunc or !is_number($returnfromfunc)) {
         // undo everything we can
         $modcontext = context_module::instance($this->moduleobj->coursemodule);
         $modcontext->delete();
         $DB->delete_records('course_modules', array('id' => $this->moduleobj->coursemodule));
         if (!is_number($returnfromfunc)) {
             return array(false, "{$addinstancefunction} is not a valid function");
         } else {
             return array(false, 'Cannot add new module');
         }
     }
     $this->moduleobj->instance = $returnfromfunc;
     return array(true, '');
 }
开发者ID:OBU-OBIS,项目名称:moodle-block_module_add,代码行数:35,代码来源:module_plugin_base.php


示例5: makeAccount

 public function makeAccount($Username, $Password, $Email, $SendEmail = true, $Enabled = 1, $Quiet = false)
 {
     global $DB;
     if ($this->accountNameInUse($Username) || $this->accountEmailInUse($Email)) {
         return -3;
     }
     // Create the account
     $Secret = make_secret();
     $TS = md5(time() . $Secret . time());
     $DB->query("INSERT INTO users (Username, Password, Email, Enabled, Secret, AuthKey, JoinDate) VALUES('%s', '%s', '%s', %d, '%s', '%s')", db_string($Username), db_string(make_hash($Password, $Secret)), db_string($Email), db_string($Enabled), db_string($Secret), db_string($TS), sqltime());
     $UserID = $DB->inserted_id();
     if ($SendEmail == true) {
         $EmailTemplate = file_get_contents(SERVER_ROOT . '/res/confirm_account.tpl');
         $EmailTemplate = str_replace('%Username%', $Username, $EmailTemplate);
         $EmailTemplate = str_replace('%AuthKey%', $TS, $EmailTemplate);
         $Subject = 'Redstone Mods Account Confirmation';
         $Headers = 'From: "PTPIMG Mailer" <[email protected]>' . PHP_EOL . 'X-Mailer: PHP/' . phpversion() . PHP_EOL;
         if (mail($Email, $Subject, $EmailTemplate, $Headers)) {
             if (!$Quiet) {
                 echo "Account created! Please check your email to confirm your account. You will not be able to login until you have confirmed your email address.";
             }
         } else {
             if (!$Quiet) {
                 die("Unknown error, contact admins for additional help.");
             } else {
                 die;
             }
         }
     }
     if (is_number($UserID)) {
         return $UserID;
     } else {
         return -1;
     }
 }
开发者ID:morilo,项目名称:ptpimg,代码行数:35,代码来源:class_user.php


示例6: check_error

 function check_error()
 {
     global $database;
     if ($_GET['id'] == NULL || !is_number($_GET['id']) || $database->clear_param()->select(array('*'), 'book')->where(array('id' => array('=', $_GET['id'])))->num_rows() == 0) {
         $this->error = 1;
     }
 }
开发者ID:h2dvnnet,项目名称:eLib,代码行数:7,代码来源:book.php


示例7: validateValue

 function validateValue($value)
 {
     if ($this->mandatory && empty($value)) {
         return 'Mandatory!';
     }
     if ($this->input_regexp && !preg_match('#' . $this->input_regexp . '#', $value)) {
         return 'Invalid format. Must be: ' . $this->input_regexp;
     }
     $options = $this->parseOptions($this->input_format);
     switch ($this->field_type) {
         case 'multistring':
             if (isset($options['options'])) {
                 $selected = array_intersect($options['options'], (array) $value);
                 if ($this->mandatory && !$selected) {
                     return 'Mandatory!';
                 } else {
                     if (isset($options['min']) && (int) $options['min'][0] > count($selected)) {
                         return 'Too few options selected';
                     } else {
                         if (isset($options['max']) && (int) $options['max'][0] < count($selected)) {
                             return 'Too many options selected';
                         }
                     }
                 }
             }
             break;
         case 'integer':
             if ((string) (int) $value !== (string) $value) {
                 return 'Invalid number';
             }
             break;
         case 'float':
             if (!is_number($value)) {
                 return 'Invalid number';
             }
             break;
         case 'date':
             if (!preg_match('#^\\d\\d\\d\\d\\-\\d\\d?\\-\\d\\d?$#', $value)) {
                 return 'Invalid date';
             }
             break;
         case 'time':
             if (!preg_match('#^\\d\\d?:\\d\\d?(?::\\d\\d?)?$#', $value)) {
                 return 'Invalid time';
             }
             break;
         case 'dateandtime':
             if (!preg_match('#^\\d\\d\\d\\d\\-\\d\\d?\\-\\d\\d? \\d\\d?:\\d\\d?(?::\\d\\d?)?$#', $value)) {
                 return 'Invalid date+time';
             }
             break;
         case 'reference':
             if (!$this->getDbObject()->count('nodes', 'id = ' . (int) $value . ' AND node_type_id IN (' . implode(',', $options['node_types']) . ')')) {
                 return 'Invalid reference (' . (int) $value . ' not found)';
             }
             break;
     }
     return true;
 }
开发者ID:rudiedirkx,项目名称:CMS2,代码行数:59,代码来源:inc.cls.aronodetypefield.php


示例8: handle_p

 function handle_p()
 {
     if (isset($_GET['p']) && is_number($_GET['p']) && +$_GET['p'] > 0 && +$_GET['p'] <= $this->page) {
         $this->p = +$_GET['p'];
     } else {
         $this->p = 1;
     }
 }
开发者ID:h2dvnnet,项目名称:eLib,代码行数:8,代码来源:contributed.php


示例9: getRowById

 public function getRowById($id)
 {
     if (!is_number($id)) {
         return false;
     }
     $select = $this->select();
     $select->where('id = ?', (int) $id);
     return $this->fetchRow($select);
 }
开发者ID:shadobladez,项目名称:erp2,代码行数:9,代码来源:Application.php


示例10: __construct

 public function __construct($data, $language = null)
 {
     if (is_number($data)) {
         $this->id = $data;
         $db = \TMDB\Client::getInstance();
         $data = $this->l1st($language);
     }
     parent::__construct($data);
 }
开发者ID:ahmetozantekin,项目名称:TMDB4PHP,代码行数:9,代码来源:Genre.php


示例11: sql

 /**
  * Search by input value
  */
 public function sql()
 {
     global $DB;
     $preference = $this->preferences_get($this->name);
     if (!empty($preference) or is_number($preference)) {
         return array($DB->sql_like($this->field, '?', false, false), "%{$preference}%");
     }
     return false;
 }
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:12,代码来源:text.php


示例12: testIsNumberFalse

 public function testIsNumberFalse()
 {
     // arrange
     $array = array(null, "three", "27");
     // act
     // assert
     foreach ($array as $value) {
         $this->assertFalse(is_number($value), 'Expected value to not be identified as a number.');
     }
 }
开发者ID:npmweb,项目名称:php-helpers,代码行数:10,代码来源:TypeHelpersTest.php


示例13: validation

 public function validation($data, $files)
 {
     global $CFG;
     $cost = $data['cost'];
     $errors = array();
     if (!is_number($cost)) {
         $errors['cost'] = get_string('numericplease', 'mod_emarking');
         return $errors;
         return $errors;
     }
 }
开发者ID:hansnok,项目名称:emarking,代码行数:11,代码来源:exammodification_form.php


示例14: set_id

 /**
  * Set the ID to null or to a positive whole number
  *
  * @throws coding_exception
  * @param int|null $id
  * @return mr_model_record_abstract
  */
 public function set_id($id)
 {
     if (!is_number($id) and !is_null($id)) {
         throw new coding_exception('ID must be a number or NULL');
     }
     if (!is_null($id) and $id < 1) {
         throw new coding_exception('ID must be a positive, non-zero number');
     }
     $this->id = $id;
     return $this;
 }
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:18,代码来源:abstract.php


示例15: filterBycountry

 public function filterBycountry($country)
 {
     if (is_object($country)) {
         $id = $country->getId();
     } elseif (is_number($country)) {
         $id = $country;
     } else {
         return null;
     }
     return $this->leftJoin($this->getRootAlias() . '.District d')->leftJoin('d.Zone z')->andWhere('z.country_id = ?', $id);
 }
开发者ID:ner0tic,项目名称:scss,代码行数:11,代码来源:ScssStaffQuery.class.php


示例16: validation

 public function validation($data, $files)
 {
     $errors = array();
     if (!is_number($data['cost'])) {
         $errors['cost'] = get_string('numericplease', 'mod_emarking');
     }
     if (!is_number($data['costcenter'])) {
         $errors['costcenter'] = get_string('numericplease', 'mod_emarking');
     }
     return $errors;
 }
开发者ID:hansnok,项目名称:emarking,代码行数:11,代码来源:cost_form.php


示例17: xmldb_enrol_imsenterprise_upgrade

function xmldb_enrol_imsenterprise_upgrade($oldversion)
{
    global $CFG, $DB, $OUTPUT;
    $dbman = $DB->get_manager();
    //NOTE: this file is not executed during upgrade from 1.9.x!
    if ($oldversion < 2011013000) {
        // this plugin does not use the new file api - lets undo the migration
        $fs = get_file_storage();
        if ($DB->record_exists('course', array('id' => 1))) {
            //course 1 is hardcoded here intentionally!
            if ($context = get_context_instance(CONTEXT_COURSE, 1)) {
                if ($file = $fs->get_file($context->id, 'course', 'legacy', 0, '/', 'imsenterprise-enrol.xml')) {
                    if (!file_exists("{$CFG->dataroot}/1/imsenterprise-enrol.xml")) {
                        check_dir_exists($CFG->dataroot . '/');
                        $file->copy_content_to("{$CFG->dataroot}/1/imsenterprise-enrol.xml");
                    }
                    $file->delete();
                }
            }
        }
        if (!empty($CFG->enrol_imsfilelocation)) {
            if (strpos($CFG->enrol_imsfilelocation, "{$CFG->dataroot}/") === 0) {
                $location = str_replace("{$CFG->dataroot}/", '', $CFG->enrol_imsfilelocation);
                $location = str_replace('\\', '/', $location);
                $parts = explode('/', $location);
                $courseid = array_shift($parts);
                if (is_number($courseid) and $DB->record_exists('course', array('id' => $courseid))) {
                    if ($context = get_context_instance(CONTEXT_COURSE, $courseid)) {
                        $file = array_pop($parts);
                        if ($parts) {
                            $dir = '/' . implode('/', $parts) . '/';
                        } else {
                            $dir = '/';
                        }
                        if ($file = $fs->get_file($context->id, 'course', 'legacy', 0, $dir, $file)) {
                            if (!file_exists($CFG->enrol_imsfilelocation)) {
                                check_dir_exists($CFG->dataroot . '/' . $courseid . $dir);
                                $file->copy_content_to($CFG->enrol_imsfilelocation);
                            }
                            $file->delete();
                        }
                    }
                }
            }
        }
        upgrade_plugin_savepoint(true, 2011013000, 'enrol', 'imsenterprise');
    }
    // Moodle v2.1.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.2.0 release upgrade line
    // Put any upgrade step following this
    return true;
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:53,代码来源:upgrade.php


示例18: filter_tags

/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_tags(&$Form)
{
    $Form->text_input('tag_filter', get_param('tag_filter'), 24, T_('Tag'), '', array('maxlength' => 50));
    $item_ID_filter_note = '';
    if ($filter_item_ID = get_param('tag_item_ID')) {
        // check item_Id filter. It must be a number
        if (!is_number($filter_item_ID)) {
            // It is not a number
            $item_ID_filter_note = T_('Must be a number');
        }
    }
    $Form->text_input('tag_item_ID', $filter_item_ID, 9, T_('Post ID'), $item_ID_filter_note, array('maxlength' => 9));
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:18,代码来源:_itemtags.view.php


示例19: log

 /**
  * Logs with an arbitrary level.
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     global $DB;
     $data = '';
     foreach ($context as $key => $val) {
         $data .= $data != '' ? "\n\n" : '';
         if (!is_number($key)) {
             $data .= $key . "\n\n";
         }
         $data .= $val;
         $data .= "\n" . str_repeat('-', 80);
     }
     return $DB->insert_record('collaborate_log', (object) ['time' => time(), 'level' => $level, 'message' => $message, 'data' => $data]);
 }
开发者ID:mpetrowi,项目名称:moodle-mod_collaborate,代码行数:22,代码来源:loggerdb.php


示例20: __construct

 /**
  * Constructor.
  *
  * @param \stdClass $structure Data structure from JSON decode
  * @throws \coding_exception If invalid data structure.
  */
 public function __construct($structure)
 {
     // Get cmid.
     if (isset($structure->cm) && is_number($structure->cm)) {
         $this->cmid = (int) $structure->cm;
     } else {
         throw new \coding_exception('Missing or invalid ->cm for completion condition');
     }
     // Get expected completion.
     if (isset($structure->e) && in_array($structure->e, array(COMPLETION_COMPLETE, COMPLETION_INCOMPLETE, COMPLETION_COMPLETE_PASS, COMPLETION_COMPLETE_FAIL))) {
         $this->expectedcompletion = $structure->e;
     } else {
         throw new \coding_exception('Missing or invalid ->e for completion condition');
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:21,代码来源:condition.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP is_numeric函数代码示例发布时间:2022-05-15
下一篇:
PHP is_null函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap