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


PHP is_number函数代码示例

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


在下文中一共展示了is_number函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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" <noreply+ptpimg@nervex.net>' . 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


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