In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use data types and constants in php. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
SetType-sets the type of variable
Bool settype (mixed $var, string $type)
Set the type of variable var to type.
The possible values for type are:
"boolean" (or "bool", starting with PHP 4.2.0)
"integer" (or "int", starting with PHP 4.2.0)
"float" (available only after PHP 4.2.0, "double" used in older versions is now disabled)
"string"
"array"
"object"
"null" (since PHP 4.2.0)
TRUE is returned if successful, FALSE is returned if failed.
Intval (), floatval (), stringval () do not change the type of the original variable.
Isset- detects whether the variable is set
Bool isset (mixed $var [, mixed $var [, $...]])
Returns TRUE if var exists, FALSE otherwise.
If you have released a variable using unset (), it will no longer be isset (). If you use isset () to test a variable that is set to NULL, it returns FALSE. Also note that a NULL byte ("\ 0") is not equal to the NULL constant of PHP.
Note: warning isset () can only be used for variables, because passing any other parameters will cause parsing errors. To detect whether the constant is set, you can use the defined () function.
Empty-check if a variable is empty
Bool empty (mixed $var)
If var is a nonnull or non-zero value, empty () returns FALSE. In other words, "", 0, "0", NULL, FALSE, array (), var $var;, and objects without any attributes will be considered empty. If var is empty, TRUE will be returned without warning if the variable has no value.
Unset-release the given variable
Void unset (mixed $var [, mixed $var [, $...]])
Unset () destroys the specified variable. Note that in PHP 3, unset () returns TRUE (actually an integer value of 1), while in PHP 4, unset () is no longer a real function: it is now a statement. There is no return value, and trying to get the return value of unset () will result in a parsing error.
Gettype-gets the type of variable
String gettype (mixed $var)
Returns the type of PHP variable var.
Variable type test function
Is_bool ()
Is_int ()
Is_integer ()
Is_long ()
Is_string ()
Is_float ()
Is_double ()
Is_real ()
Is_array ()
Is_object ()
Is_resource ()
Is_null ()
Is_scalar ()
Is_numberic ()
Is_callable ()
Notes for consulting the manual
1. Conventional function
Bool copy (string source, string dest)
two。 With mixed, mixed means any type of data can be passed.
Bool chown (string filename, mixed user)
3. A function with a & parameter indicates a reference assignment. This parameter cannot pass a value, but can only pass a variable, and then the function changes the value of the variable. When we use this variable, the value also changes.
Bool arsort (array & array [, int sort_flags])
4. The default function has a function of [], indicating that this parameter is optional. If you pass a value, use the value you passed, and if there is no value, use the default value.
When you declare a function directly, you give the initial value for the parameter.
Optional and required values, which must be set from back to front
Bool arsort (array & array [, int sort_flags])
5. With. The parameter function of. Indicates that any number of parameters can be passed
Int array_unshift (array & array, mixed var [, mixed...])
6. The callback function has callback, which means we need to pass in a function (function name, function name string) when calling this function.
Array array_filter (array input [, callback callback])
This is the end of this article on "how to use data types and constants in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.