|
|
These functions check the status of a variable, change its type, or return a value as a particular data type.
boolean define(string name, value, boolean non_case_sensitive)
The define function creates a constant, which is essentially a variable that may be set only once. The value argument may be a string, integer, double, or boolean. It may not be an array or object. The non_case_sensitive argument is optional. By default, constants are case sensitive, which is the same as with variables. If the constant cannot be created for some reason, FALSE will be returned. If you wish to check that a constant is defined, use the defined function. It is customary to name constants using all uppercase letters, as is the practice in C. This makes them stand out among other identifiers.
Because PHP allows for unquoted string literals, it is possible to write code that uses constants that do not exist, yet produces no error. When you are using constants to hold strings to be displayed on the page, this is simply an annoyance, because you can see the error right away. When used for values not displayed, it can be a frustrating source of bugs. If you discover a constant mysteriously evaluating to zero, check that the constant has been defined.
<?boolean defined(string constantname)
The defined function returns TRUE if a constant exists, FALSE otherwise.
double doubleval(expression)
The doubleval function returns its argument as a double. discusses converting between data types. Related functions are strval and intval. It is an error to pass an array or object to doubleval.
empty
This function is an alias for isset.
string gettype(expression)
The gettype function returns a string that describes the type of the variable or expression. It will be one of the following values: array, class, double, integer,
object, resource, string, unknown type.
integer intval(expression, integer base)
The intval function returns its argument as an integer. The optional base argument instructs intval to use a numerical base other than ten.
boolean is_array(expression)
The is_array function returns TRUE if the expression is an array, otherwise FALSE is
returned.
boolean is_bool(expression)
Use is_bool to test whether an expression is a boolean.
boolean is_double(expression)
The is_double function returns TRUE if the expression is a double, FALSE otherwise.
is_float
The is_float function is an alias for the is_double function.
is_int
The is_int function is an alias for the is_integer function.
boolean is_integer(expression)
The is_integer function returns TRUE if the expression is an integer, FALSE otherwise.
is_long
The is_long function is an alias for the is_integer function.
boolean is_object(expression)
The is_object function returns TRUE if the expression is an object, FALSE otherwise.
boolean is_real(expression)
The is_real function is an alias for the is_double function.
boolean is_resource(variable)
This function returns TRUE if the given variable is a resource. A resource is an integer used to identify a system resource. An example is the return value of fopen.
boolean is_string(expression)
The is_string function returns TRUE if the expression is a string, FALSE otherwise.
boolean isset(variable)
The isset function returns TRUE if the variable has been given a value, or FALSE if the variable has never been on the left side of a set operator. In other words, it tests that the variable has been set with a value.
boolean settype(variable, string type)
The settype function changes the type of a variable. The type is written as a string and may be one of the following: array, double, integer, object, string. If the type could not be set, FALSE is returned.
string strval(expression)
The strval function returns its argument as a string.
unset(variable)
The unset function destroys a variable, causing all memory associated with the variable to be freed.
|
|
PHP Related Tutorials |
|
---|---|
MySQL Tutorial | Drupal Tutorial |
WordPress Tutorial | Joomla Tutorial |
CakePHP Tutorial | CodeIgniter Tutorial |
PHP7 Tutorial |
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.