本文整理汇总了PHP中is_real函数的典型用法代码示例。如果您正苦于以下问题:PHP is_real函数的具体用法?PHP is_real怎么用?PHP is_real使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_real函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getValueInfo
/**
* return stacktrace-like information about the given variable
*
* @return string
*/
function getValueInfo($val)
{
if (is_null($val)) {
return 'null';
}
if (is_array($val)) {
return 'array[' . count($val) . ']';
}
if (is_bool($val)) {
return $val ? 'true' : 'false';
}
if (is_float($val) || is_int($val) || is_long($val) || is_real($val)) {
return 'num:' . $val;
}
if (is_string($val)) {
return 'string[' . strlen($val) . ']=' . substr($val, 0, 16);
}
if (is_resource($val)) {
return 'resource' . get_resource_type($val);
}
if (is_object($val)) {
return 'object';
}
return '?';
}
开发者ID:emente,项目名称:kataii---kata-framework-2.x,代码行数:30,代码来源:katafunctions.php
示例2: __construct
public function __construct($value = '', $cast = FALSE)
{
$isReal = is_real($value);
if (!$cast && !$isReal) {
throw new \Exception("Expected value must be of type float/double, " . gettype($value) . " given");
}
if ($cast && !$isReal) {
return $this->value = (double) $value;
}
$this->value = $value;
}
开发者ID:pthreat,项目名称:apf-dev,代码行数:11,代码来源:Real.class.php
示例3: guessType
/**
* Guess the type of a variable.
*
* @ingroup config
* @param $value (mixed) the var
* @return (const type)
*/
function guessType($value)
{
if (is_bool($value)) {
return BOOL;
} elseif (is_real($value)) {
return REAL;
} elseif (is_int($value)) {
return NUMERIC;
} else {
return STRING;
}
}
开发者ID:BackupTheBerlios,项目名称:morgos-svn,代码行数:19,代码来源:config.class.php
示例4: checkValues
function checkValues($timestamp, $device, $latitude, $longitude, $message)
{
if (!is_integer($timestamp) || $timestamp <= 0) {
throw new Exception("Timestamp must be a a positive integer");
} elseif (!is_string($device) || !preg_match(AzimutDatabase::REGEX_DEVICE, $device)) {
throw new Exception("The field '" . AzimutDatabase::FIELD_DEVICE . "' must match " . AzimutDatabase::REGEX_DEVICE);
} elseif (!is_string($message) || !preg_match(AzimutDatabase::REGEX_MESSAGE, $message)) {
throw new Exception("The field '" . AzimutDatabase::FIELD_MESSAGE . "' must match " . AzimutDatabase::REGEX_MESSAGE);
} elseif (!is_real($latitude) || $latitude < -90 || $latitude > 90) {
throw new Exception("The field '" . AzimutDatabase::FIELD_LATITUDE . "' must be a float between -90 and 90");
} elseif (!is_real($longitude) || $longitude < -360 || $longitude > 360) {
throw new Exception("The field '" . AzimutDatabase::FIELD_LONGITUDE . "' must be a float between -360 and 360");
}
}
开发者ID:essembeh,项目名称:azimut,代码行数:14,代码来源:AzimutDatabase.class.php
示例5: foo
function foo()
{
echo "set: " . isset($a) . "\n";
echo "nul: " . is_null($a) . "\n";
echo "str: " . is_string($a) . "\n";
echo "obj: " . is_object($a) . "\n";
echo "arr: " . is_array($a) . "\n";
echo "int: " . is_int($a) . "\n";
echo "integer: " . is_integer($a) . "\n";
echo "long: " . is_long($a) . "\n";
echo "real: " . is_real($a) . "\n";
echo "double: " . is_double($a) . "\n";
echo "float: " . is_float($a) . "\n";
echo "bool: " . is_bool($a) . "\n";
}
开发者ID:n3b,项目名称:hiphop-php,代码行数:15,代码来源:undefined_is_type.php
示例6: toPrimitiveType
public function toPrimitiveType($value)
{
if (is_null($value)) {
return null;
}
if (is_string($value)) {
$value = trim($value);
if (empty($value)) {
return null;
} else {
return $this->toNumeric($value);
}
}
if (is_integer($value) || is_long($value) || is_double($value) || is_float($value) || is_real($value) || is_numeric($value)) {
return $this->toNumeric($value);
}
throw new Exception("Invalid {$this->typeprefix}.");
}
开发者ID:AyrtonRicardo,项目名称:simpletablereport,代码行数:18,代码来源:NumericType.php
示例7: generateHash
/**
* @internal
*
* Create hash for each element.
*
* @param $value
* @return string
*/
protected function generateHash($value)
{
if (is_object($value)) {
if ($value instanceof \Closure) {
throw new \InvalidArgumentException("Closure cannot be Dictionary key.");
}
return 'object:' . spl_object_hash($value);
} elseif (is_string($value)) {
return 'string:' . $value;
} elseif (is_int($value)) {
return 'int:' . $value;
} elseif (is_real($value)) {
return 'float:' . $value;
} elseif (is_bool($value)) {
return 'bool:' . (int) $value;
} elseif (is_null($value)) {
return 'null:null';
} else {
throw new \InvalidArgumentException("Invalid Dictionary key.");
}
}
开发者ID:dpolac,项目名称:dictionary,代码行数:29,代码来源:Dictionary.php
示例8: checkType
private function checkType($obj, $escalate = true)
{
switch ($this->type) {
case 'string':
$valid = is_string($obj);
break;
case 'array':
$valid = is_array($obj);
break;
case 'bool':
case 'boolean':
$valid = is_bool($obj);
break;
case 'double':
$valid = is_double($obj);
break;
case 'real':
$valid = is_real($obj);
break;
case 'float':
$valid = is_float($obj);
break;
case 'int':
case 'integer':
$valid = is_int($obj);
break;
case 'object':
$valid = is_object($obj);
break;
default:
$valid = $obj instanceof $this->type;
break;
}
if (!$valid && $escalate) {
throw new InvalidArgumentException('Argument must be of type "' . $this->type . '".');
}
return $valid;
}
开发者ID:bigwhoop,项目名称:hynage,代码行数:38,代码来源:Generic.php
示例9: foo
function foo()
{
// Force all the types to be in so these don't get constant folded.
if (isset($GLOBALS['a'])) {
$a = 1;
}
if (isset($GLOBALS['b'])) {
$a = 1.2;
}
if (isset($GLOBALS['c'])) {
$a = '1';
}
if (isset($GLOBALS['d'])) {
$a = new stdclass();
}
if (isset($GLOBALS['e'])) {
$a = array();
}
if (isset($GLOBALS['f'])) {
$a = false;
}
if (isset($GLOBALS['g'])) {
$a = null;
}
echo "set: ", isset($a) . "\n";
echo "nul: ", is_null($a) . "\n";
echo "str: ", is_string($a) . "\n";
echo "obj: ", is_object($a) . "\n";
echo "arr: ", is_array($a) . "\n";
echo "int: ", is_int($a) . "\n";
echo "integer: ", is_integer($a) . "\n";
echo "long: ", is_long($a) . "\n";
echo "real: ", is_real($a) . "\n";
echo "double: ", is_double($a) . "\n";
echo "float: ", is_float($a) . "\n";
echo "bool: ", is_bool($a) . "\n";
}
开发者ID:badlamer,项目名称:hhvm,代码行数:37,代码来源:undefined_is_type.php
示例10: check
function check($var)
{
if (is_array($var)) {
emitType($var);
} elseif (is_bool($var)) {
emitType($var);
} elseif (is_callable($var)) {
emitType($var);
} elseif (is_double($var)) {
emitType($var);
} elseif (is_float($var)) {
emitType($var);
} elseif (is_int($var)) {
emitType($var);
} elseif (is_integer($var)) {
emitType($var);
} elseif (is_bool($var)) {
emitType($var);
} elseif (is_long($var)) {
emitType($var);
} elseif (is_null($var)) {
emitType($var);
} elseif (is_numeric($var)) {
emitType($var);
} elseif (is_object($var)) {
emitType($var);
} elseif (is_real($var)) {
emitType($var);
} elseif (is_resource($var)) {
emitResourceType($var);
} elseif (is_scalar($var)) {
emitType($var);
} elseif (is_string($var)) {
emitType($var);
}
}
开发者ID:tpunt,项目名称:phan,代码行数:36,代码来源:0166_is_a.php
示例11: getMysqlTypeForValue
/**
* will determine a valid mysql column type from
* the input variable value
*/
protected function getMysqlTypeForValue($val)
{
if (preg_match('/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/', $val)) {
return "DATETIME";
} else {
if (is_string($val)) {
return "TEXT";
} else {
if (is_bool($val)) {
return "TINYINT";
} else {
if (is_int($val)) {
return "BIGINT";
} else {
if (is_double($val) || is_float($val) || is_real($val)) {
return "DOUBLE";
} else {
echo "unknown mysql type for: " . gettype($val) . "\n";
}
}
}
}
}
}
开发者ID:mhscientist,项目名称:json-to-mysql,代码行数:28,代码来源:class.AbstractMysqlTable.php
示例12: set_migration_column_attributes
/**
* Set the attributes of the migration
*
* @access private
* @param array $args Migration column attibutes
* @return void
* @author Aziz Light
**/
private function set_migration_column_attributes(array $args)
{
$extra = "\t\t\t'" . $args['column_name'] . '\' => array(' . PHP_EOL;
unset($args['column_name']);
foreach ($args as $attr => $value) {
$extra .= "\t\t\t\t'" . substr($attr, 7) . "' => ";
if (is_int($value) || is_real($value)) {
$extra .= $value;
} else {
if (is_bool($value)) {
$extra .= $value ? 'TRUE' : 'FALSE';
} else {
$extra .= "'" . $value . "'";
}
}
$extra .= ',' . PHP_EOL;
}
$extra .= "\t\t\t)," . PHP_EOL;
$this->extra = $extra;
return;
}
开发者ID:NaszvadiG,项目名称:Base-CodeIgniter-App,代码行数:29,代码来源:template_scanner.php
示例13: IsNotReal
public function IsNotReal()
{
$this->AddResult(!is_real($this->MethodOutput), 'Expected to be different from real (the number type!)');
}
开发者ID:essentialmanager,项目名称:emx,代码行数:4,代码来源:emx-units.php
示例14: devuelve_apostrofe
private function devuelve_apostrofe($variable)
{
$apostrofe = "";
switch (true) {
case is_bool($variable):
case is_double($variable):
case is_float($variable):
case is_int($variable):
case is_integer($variable):
case is_long($variable):
case is_numeric($variable):
case is_real($variable):
$apostrofe = "'";
break;
case is_string($variable):
$apostrofe = "'";
break;
default:
$apostrofe = '';
break;
}
return $apostrofe;
}
开发者ID:jbetan,项目名称:siri1.2,代码行数:23,代码来源:class_mysqlconnector_ocs.php
示例15: decimal
function decimal($field, $value)
{
if (is_numeric($value) || is_real($value)) {
$value = sprintf("%01.3f", $value);
}
$isValid = preg_match("/^([0-9]{1,5}[.]{1}[0-9]{1,5})\$/", $value);
if (!$isValid) {
$msg = "<span class=\"varname\">\"" . $this->field_label . "\"</span> A valid decimal value";
$this->error_list[] = array("field" => $field, "value" => $value, "msg" => $msg);
}
return $isValid;
}
开发者ID:CDESmith,项目名称:newtwo,代码行数:12,代码来源:class.validator.php
示例16: is
/**
* @param mixed $variable
* @param $type
*
* @return bool
*/
public static function is($variable, $type)
{
if (!in_array($type, [self::TYPE_ARRAY, self::TYPE_BOOLEAN, self::TYPE_CALLABLE, self::TYPE_DOUBLE, self::TYPE_FLOAT, self::TYPE_INT, self::TYPE_INTEGER, self::TYPE_LONG, self::TYPE_NULL, self::TYPE_NUMERIC, self::TYPE_OBJECT, self::TYPE_REAL, self::TYPE_RESOURCE, self::TYPE_SCALAR, self::TYPE_STRING])) {
return false;
}
switch ($type) {
case self::TYPE_ARRAY:
return is_array($variable);
case self::TYPE_BOOLEAN:
return is_bool($variable);
case self::TYPE_CALLABLE:
return is_callable($variable);
case self::TYPE_DOUBLE:
return is_double($variable);
case self::TYPE_FLOAT:
return is_float($variable);
case self::TYPE_INT:
return is_int($variable);
case self::TYPE_INTEGER:
return is_integer($variable);
case self::TYPE_LONG:
return is_long($variable);
case self::TYPE_NULL:
return is_null($variable);
case self::TYPE_NUMERIC:
return is_numeric($variable);
case self::TYPE_OBJECT:
return is_object($variable);
case self::TYPE_REAL:
return is_real($variable);
case self::TYPE_RESOURCE:
return is_resource($variable);
case self::TYPE_SCALAR:
return is_scalar($variable);
case self::TYPE_STRING:
return is_string($variable);
default:
return false;
}
}
开发者ID:nox-it,项目名称:yii2-nox-helpers,代码行数:46,代码来源:VariablesHelper.php
示例17: export_data
function export_data($fp, $name, $value)
{
global $ARCurrent;
if (!is_null($value)) {
fwrite($fp, "<var name=\"{$name}\">\n");
if (is_bool($value)) {
$value = $value ? 'true' : 'false';
fwrite($fp, "<boolean>{$value}</boolean>\n");
} else {
if (is_int($value) || is_real($value) || is_float($value)) {
fwrite($fp, "<number>{$value}</number>\n");
} else {
if (is_string($value) || $value === "") {
if ($ARCurrent->wddxoptions['srcpath'] != $ARCurrent->wddxoptions['dstpath']) {
$value = preg_replace('#(^|[\'"])' . $ARCurrent->wddxoptions['srcpath'] . '#i', '$1' . $ARCurrent->wddxoptions['dstpath'], $value);
}
fwrite($fp, "<string><![CDATA[" . export_wddx::strtoxmldata($value) . "]]></string>\n");
} else {
if (is_array($value) || is_object($value)) {
if (is_array($value)) {
fwrite($fp, "<struct type=\"hash\">\n");
} else {
fwrite($fp, "<struct type=\"object\" class=\"" . get_class($value) . "\">\n");
}
foreach ($value as $key => $val) {
export_wddx::export_data($fp, $key, $val);
}
fwrite($fp, "</struct>\n");
}
}
}
}
fwrite($fp, "</var>\n");
}
}
开发者ID:poef,项目名称:ariadne,代码行数:35,代码来源:mod_export_wddx.php
示例18: unset
// unset variable
$unset_var = 10;
unset($unset_var);
// non_scalar values, objects, arrays, resources and boolean
class foo
{
var $array = array(10.5);
}
$object = new foo();
$not_floats = array(new foo(), $object, $fp, $dfp, array(), array(NULL), array(5000000000.0), array(1, 2, 3, 4), array("string"), NULL, null, true, TRUE, false, FALSE, "", '', "0", '0', "0.0", '0.0', '0.5', "-0.5", "1e5", '1e5', '1.5e6_string', "1.5e6_string", 1, -1, 0, 12345, 0xff55, -0x673, 0123, -0123, @$unset_var, @$undefined_var);
/* loop through the $not_floats to see working of
is_float(), is_double() & is_real() on objects,
arrays, boolean and others */
$loop_counter = 1;
foreach ($not_floats as $value) {
echo "--Iteration {$loop_counter}--\n";
$loop_counter++;
var_dump(is_float($value));
var_dump(is_double($value));
var_dump(is_real($value));
}
echo "\n*** Testing error conditions ***\n";
//Zero argument
var_dump(is_float());
var_dump(is_double());
var_dump(is_real());
//arguments more than expected
var_dump(is_float($floats[0], $floats[1]));
var_dump(is_double($floats[0], $floats[1]));
var_dump(is_real($floats[0], $floats[1]));
echo "Done\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:is_float_64bit.php
示例19: isReal
function isReal($d)
{
trueOrX(is_real($d), "not a real");
return $d;
}
开发者ID:netom,项目名称:colander,代码行数:5,代码来源:colander.php
示例20: _parseVariable
/**
* _parseVariable() - Parse (recursively) a variable
*
* This method parse a variable, either returning informations about
* this variable, or in the case of an object or array, returning
* recursive informations about this variable.
*
* @param $variable A variable to explore
*/
function _parseVariable($variable)
{
$lang = $this->lang;
if (is_object($variable)) {
return $this->_parseObject($variable);
} elseif (is_array($variable)) {
return $this->_parseArray($variable);
} elseif (is_long($variable)) {
$type = $this->messages['TYPE_LONG'][$lang];
} elseif (is_int($variable)) {
$type = $this->messages['TYPE_INT'][$lang];
} elseif (is_integer($variable)) {
$type = $this->messages['TYPE_INTEGER'][$lang];
} elseif (is_double($variable)) {
$type = $this->messages['TYPE_DOUBLE'][$lang];
} elseif (is_float($variable)) {
$type = $this->messages['TYPE_FLOAT'][$lang];
} elseif (is_real($variable)) {
$type = $this->messages['TYPE_REAL'][$lang];
} elseif (is_string($variable)) {
$type = $this->messages['TYPE_STRING'][$lang] . '[' . strlen($variable) . ']';
} elseif (is_bool($variable)) {
$type = $this->messages['TYPE_BOOLEAN'][$lang];
if ($variable == true) {
$variable = $this->messages['BOOLEAN_TRUE'][$lang];
} else {
$variable = $this->messages['BOOLEAN_FALSE'][$lang];
}
} elseif (is_numeric($variable)) {
$type = $this->messages['TYPE_NUMERIC'][$lang];
} elseif (is_resource($variable)) {
$type = $this->messages['TYPE_RESOURCE'][$lang] . '[' . get_resource_type($variable) . ']';
} elseif (is_scalar($variable)) {
$type = $this->messages['TYPE_SCALAR'][$lang];
} elseif (is_null($variable)) {
$type = $this->messages['TYPE_NULL'][$lang];
$variable = 'Null';
} else {
$type = $this->messages['TYPE_UNKNOWN'][$lang] . '[' . gettype($variable) . ']';
}
return array(VAR_DUMP_ARRAY_MAGIC => VAR_DUMP_MAGIC, VAR_DUMP_ARRAY_TYPE => $type, VAR_DUMP_ARRAY_VALUE => $variable);
}
开发者ID:amjadtbssm,项目名称:website,代码行数:51,代码来源:Var_Dump.php
注:本文中的is_real函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论