echo intval"123";//displays 123 echo intval"10",16;//displays 16 is_array Syntax int is_arraymixed var Description The is_array function returns true if var is an array and returns f
Trang 1The trim() function removes whitespace from str and returns the resulting string
Whitespace includes "\\ n", "\\ r", "\\ t", "\\ v", "\\ 0", and a plain space
ucfirst
Syntax
string ucfirst(string str)
Description
The ucfirst() function capitalizes the first character of str if it is alphabetic The
alphabet is determined by the current locale setting
$text = "hello world!";
echo ucfirst($text);//displays Hello world!
ucwords()
Syntax
string ucwords(string str)
Description
The ucwords() function, which was added in PHP 3.0.3 and PHP 4.0, returns a string that is str with each word's first letter uppercased if it is alphabetic
$text = "hello world!";
echo ucwords($text);//displays Hello World!
Variable
The following functions deal primarily with getting and setting variable types
doubleval()
Syntax
Trang 2Description
The doubleval() function returns the double (floating-point) value of the var parameter The var parameter must be a scalar type and not an object or array
empty()
Syntax
int empty(mixed var)
Description
The empty() function determines whether a variable is set It returns false if var is
set to a nonempty or nonzero value, and true otherwise
gettype()
Syntax
string gettype(mixed var)
Description
The gettype() function returns the PHP-defined type of the parameter var Possible
PHP types include integer, double, string, array, object, and unknown type
$avar = array(1,2,3);
echo gettype($avar);//displays array
intval()
Syntax
int intval(mixed var, int [base])
Description
Trang 3The intval() function returns the integer value of the parameter var using the
specified base for the conversion base is an optional parameter with 10 as the
default The parameter var may be any scalar type Note that you cannot use
intval() on arrays or objects
echo (intval("123"));//displays 123
echo (intval("10",16));//displays 16
is_array()
Syntax
int is_array(mixed var)
Description
The is_array() function returns true if var is an array and returns false otherwise
is_boolean()
Syntax
int is_bool(mixed var)
Description
The is_bool() function, which was added in PHP 4.0b4, returns true if var is a
Boolean value and returns false otherwise
is_double()
Syntax
int is_double(mixed var)
Description
The is_double() function returns true if var is a double and returns false otherwise
Trang 4is_float()
Syntax
int is_float(mixed var)
Description
The is_float() function returns true if var is a double and returns false otherwise
This function is an alias for is_double()
is_int()
Syntax
int is_int(mixed var)
Description
The is_int() function returns true if var is an integer (long) and returns false
otherwise This function is an alias for is_long()
is_integer()
Syntax
int is_integer(mixed var)
Description
The is_integer() function returns true if var is an integer ( long) and returns false
otherwise This function is an alias for is_long()
is_long()
Syntax
int is_long(mixed var)
Trang 5Description
The is_long() function returns true if var is an integer (long) and returns false
otherwise
is_numeric()
Syntax
int is_numeric(mixed var)
Description
The is_numeric() function, which was added in PHP 4.0RC1, returns true if var is a
number or a numeric string and returns false otherwise
is_object()
Syntax
int is_object(mixed var)
Description
The is_object() function returns true if var is an object and returns false
otherwise
is_real()
Syntax
int is_real(mixed var)
Description
The is_real() function returns true if var is a double, and returns false otherwise
This function is an alias for is_double()
is_string()