PHP » PYTHON |
login |
register |
about
|
PYTHON is_scalar
is this article helpful?
|
Python replacement for PHP's is_scalar
[
edit
| history
]
def is_scalar (value): return isinstance(value,(type(None),str,int,float,bool,unicode)) is_scalar(PHP 4 >= 4.0.5, PHP 5) is_scalar — Finds whether a variable is a scalar DescriptionFinds whether the given variable is a scalar. Scalar variables are those containing an integer, float, string or boolean. Types array, object and resource are not scalar.
Parameters
Return ValuesReturns TRUE if var is a scalar FALSE otherwise. Examples
Example #1 is_scalar() example
<?php The above example will output: 3.1416 array(3) { [0]=> string(10) "hemoglobin" [1]=> string(20) "cytochrome c oxidase" [2]=> string(10) "ferredoxin" }
See Also
|
more
Recently updated
more
Most requested
more
Last requests
|