Common variable processing function libraries in PHP (isset (), unset (), empty, is_array ......)

Source: Internet
Author: User

Gettype: Get the type of the variable.
Intval: convert a variable to an integer.
Doubleval: convert a variable to a Double Floating Point.
Empty: determines whether the variable is configured.
Is_array: determines whether the variable type is an array type.
Is_double: determines whether the variable type is a double floating point number type.
Is_float: determines whether the variable type is of the floating point type.
Is_int: determines whether the variable type is an integer.
Is_integer: determines whether the variable type is a long integer.
Is_long: determines whether the variable type is a long integer.
Is_object: determines whether the variable type is of the class type.
Is_real: determines whether the variable type is of the real number type.
Is_string: determines whether the variable type is a string type.
Isset: determines whether the variable is configured.
Settype: configure the variable type.
Strval: convert a variable to a string type.
Unset: delete a variable.

Gettype
Get the type of the variable.
Syntax: string gettype (mixed var );
Return Value: String
Function types: PHP system functions
Description: This function is used to obtain the type of a variable. The returned type string may be one of the following strings: integer, double, string, array, object, and unknown type.
Reference: settype ()

Intval
Convert a variable to an integer.
Syntax: int intval (mixed var, int [base]);
Return Value: integer
Function types: PHP system functions
Description: This function converts a variable to an integer. The base parameter that can be omitted is the basis for conversion. The default value is 10. The converted variable var can be any type variable outside the array or class.
Reference: doubleval () strval () settype ()

Doubleval
Convert the variable type to the Double Floating Point Number type.
Syntax: double doubleval (mixed var );
Return Value: Double Floating Point Number
Function types: PHP system functions
Description: This function can convert the variable type to the Double Floating Point Number type. The converted variable var can be any type variable outside the array or class.
Reference: intval () strval () settype ()

Empty
Determine whether the variable is configured.
Syntax: int empty (mixed var );
Return Value: integer
Function types: PHP system functions
Description: This function is used to test whether the variable has been configured. If the variable already exists, non-null string, or non-zero, false is returned; otherwise, true is returned. Note that the aulbach@unter.franken.de points out (27-May-1999) If empty ($ myvar) is used )! =! Isset ($ myvar) may cause PHP processing problems.
Reference: isset () unset ()

Is_array
Determines whether the variable type is an array type.
Syntax: int is_array (mixed var );
Return Value: integer
Function types: PHP system functions
Description: If the variable is of the array type, true is returned; otherwise, false is returned.
Reference: is_double () is_float () is_int () is_integer () is_long () is_object () is_real () is_string ()

Is_double
Determines whether the variable type is a double floating point number type.
Syntax: int is_double (mixed var );
Return Value: integer
Function types: PHP system functions
Description: If the variable is of the Double Floating Point type, true is returned; otherwise, false is returned.
Reference: is_array () is_float () is_int () is_integer () is_long () is_object () is_real () is_string ()

Is_float
Determines whether the variable type is of the floating point type.
Syntax: int is_float (mixed var );
Return Value: integer
Function types: PHP system functions
Description: If the variable is of the floating point type, true is returned; otherwise, false is returned.
Reference: is_array () is_double () is_int () is_integer () is_long () is_object () is_real () is_string ()

Is_int
Determines whether the variable type is an integer.
Syntax: int is_int (mixed var );
Return Value: integer
Function types: PHP system functions
Description: If the variable is of the integer type, true is returned; otherwise, false is returned.
Reference: is_array () is_double () is_float () is_integer () is_long () is_object () is_real () is_string ()

Is_integer
Determines whether the variable type is a long integer.
Syntax: int is_integer (mixed var );
Return Value: integer
Function types: PHP system functions
Description: If the variable is of the Long Integer type, true is returned; otherwise, false is returned. This function is actually is_long ().
Reference: is_array () is_double () is_float () is_int () is_long () is_object () is_real () is_string ()

Is_long
Determines whether the variable type is a long integer.
Syntax: int is_long (mixed var );
Return Value: integer
Function types: PHP system functions
Description: If the variable is of the Long Integer type, true is returned; otherwise, false is returned.
Reference: is_array () is_double () is_float () is_int () is_integer () is_object () is_real () is_string ()

Is_object
Determines whether the variable type is of the class type.
Syntax: int is_object (mixed var );
Return Value: integer
Function types: PHP system functions
Description: If the variable is of the class type, true is returned; otherwise, false is returned.
Reference: is_array () is_double () is_float () is_int () is_integer () is_long () is_real () is_string ()

Is_real
Determines whether the variable type is a real number.
Syntax: int is_real (mixed var );
Return Value: integer
Function types: PHP system functions
Description: If the variable is of the real number type, true is returned; otherwise, false is returned.
Reference: is_array () is_double () is_float () is_int () is_integer () is_long () is_object () is_string ()

Is_string
Determines whether the variable type is a string type.
Syntax: int is_string (mixed var );
Return Value: integer
Function types: PHP system functions
Description: If the variable is of the string type, true is returned; otherwise, false is returned.
Reference: is_array () is_double () is_float () is_int () is_integer () is_long () is_object () is_real ()

Isset
Determine whether the variable is configured.
Syntax: int isset (mixed var );
Return Value: integer
Function types: PHP system functions
Description: This function is used to test whether the variable has been configured. If the variable already exists, true is returned. Otherwise, false is returned.
Example
<? Php
$ A = "test ";
Echo isset ($ a); // true
Unset ($ );
Echo isset ($ a); // false
?>
Reference: empty () unset ()

Settype
Configure the variable type.
Syntax: int settype (string var, string type );
Return Value: integer
Function types: PHP system functions
Description: This function is used to configure or convert the variable type. True is returned. Otherwise, false is returned. The var parameter is the original variable name. The type parameter is of one of the following types: integer, double, string, array, and object.
Reference: gettype ()

Strval
Convert a variable to a string type.
Syntax: string strval (mixed var );
Return Value: String
Function types: PHP system functions
Description: This function can convert an array and a variable type other than a class to a string type.
Reference: doubleval () intval () settype ()

Unset
Delete a variable.
Syntax: int unset (mixed var );
Return Value: integer
Function types: PHP system functions
Description: This function deletes the variable and returns true if it is successful.
Reference: isset () empty ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.