Menu Samaritan's Purse

FLOATVAL

Get float value of a variable

SYNTAX

floatval ( mixed $var ) : float

PARAMETERS

var

May be any scalar type

RETURN

The float value of the given variable. Empty arrays return 0, non-empty arrays return 1. Strings will most likely return 0 although this depends on the leftmost characters of the string. The common rules of float casting apply. floatval() should not be used on objects, as doing so will emit an E_NOTICE level error and return 1.

EXAMPLES

1

string(3) "0.0"
float(0)

2

NULL
float(0)

bool(false)
float(0)

bool(true)
float(1)

int(-9223372036854775808)
float(-9.2233720368548E+18)

int(9223372036854775807)
float(9.2233720368548E+18)

int(0)
float(0)

int(1)
float(1)

int(23)
float(23)

int(0)
float(0)

int(0)
float(0)

int(-1)
float(-1)

int(1)
float(1)

int(-23)
float(-23)

int(23)
float(23)

int(0)
float(0)

int(1)
float(1)

int(19)
float(19)

int(0)
float(0)

int(1)
float(1)

int(35)
float(35)

float(0)
float(0)

float(1.1)
float(1.1)

float(23.45)
float(23.45)

float(0)
float(0)

float(10000000000)
float(10000000000)

float(230000000000)
float(230000000000)

string(0) ""
float(0)

string(1) "0"
float(0)

string(1) "1"
float(1)

string(2) "23"
float(23)

string(2) "-0"
float(-0)

string(2) "+0"
float(0)

string(2) "-1"
float(-1)

string(2) "+1"
float(1)

string(3) "-23"
float(-23)

string(3) "+23"
float(23)

string(2) "00"
float(0)

string(2) "01"
float(1)

string(3) "023"
float(23)

string(3) "0x0"
float(0)

string(3) "0x1"
float(0)

string(4) "0x23"
float(0)

string(3) "0.0"
float(0)

string(3) "1.1"
float(1.1)

string(5) "23.45"
float(23.45)

string(4) "0e10"
float(0)

string(4) "1e10"
float(10000000000)

string(5) "23e10"
float(230000000000)

string(4) "0abc"
float(0)

string(4) "1abc"
float(1)

string(5) "23abc"
float(23)

string(5) "-0abc"
float(-0)

string(5) "+0abc"
float(0)

string(5) "-1abc"
float(-1)

string(5) "+1abc"
float(1)

string(6) "-23abc"
float(-23)

string(6) "+23abc"
float(23)

string(5) "00abc"
float(0)

string(5) "01abc"
float(1)

string(6) "023abc"
float(23)

string(6) "0x0abc"
float(0)

string(6) "0x1abc"
float(0)

string(7) "0x23abc"
float(0)

string(6) "0.0abc"
float(0)

string(6) "1.1abc"
float(1.1)

string(8) "23.45abc"
float(23.45)

string(7) "0e10abc"
float(0)

string(7) "1e10abc"
float(10000000000)

string(8) "23e10abc"
float(230000000000)

string(3) "abc"
float(0)

string(4) "abc0"
float(0)

string(4) "abc1"
float(0)

string(5) "abc23"
float(0)

string(5) "abc-0"
float(0)

string(5) "abc+0"
float(0)

string(5) "abc-1"
float(0)

string(5) "abc+1"
float(0)

string(6) "abc-23"
float(0)

string(6) "abc+23"
float(0)

string(5) "abc00"
float(0)

string(5) "abc01"
float(0)

string(6) "abc023"
float(0)

string(6) "abc0x0"
float(0)

string(6) "abc0x1"
float(0)

string(7) "abc0x23"
float(0)

string(6) "abc0.0"
float(0)

string(6) "abc1.1"
float(0)

string(8) "abc23.45"
float(0)

string(7) "abc0e10"
float(0)

string(7) "abc1e10"
float(0)

string(8) "abc23e10"
float(0)

array(0) {
}
float(0)

array(2) {
[0]=>
int(0)
[1]=>
int(1)
}
float(1)

INTERNAL

boolval

intval

strval

EXTERNAL

PHP