Home >Backend Development >PHP Problem >What types of php variables are there?
What is a variable
Description: A way to store data in php is the amount that i can change. This way It is to open up a space in the memory that can store data, give this space a name, and the space at this time can be called a variable. This value can be changed during operation (recommended learning: PHP video tutorial)
The name of the current space is the variable name, and the data of the current space (eight kinds of data Type) is called the variable value
Define the variable and assign the value
Define the variable: $variable name; Note that variables defined in this way are OK, but not Use, direct output will report an error, it must be followed by a variable value before you can use
to define variables and assign values: $variable name = variable value;
<?php $a; echo $a; $a =1; echo $a; ?>
Rules for defining variables
Variable names are case-sensitive
5bbff8d062b4f88c1e60850bd829b888
It is recommended to use meaningful names for variable names. When you see the variable name, you will know what it means, such as $name, Naming rules for $age, $sex, $get_user_name: must be composed of numbers, letters, and underscores and cannot start with a number. For example: $a1, $A1, $a_1, $_a1, $_2 are all acceptable but cannot be $1a.
Eight data types of variables
Scalar types: int (integer type), float (floating point type), boolean (Boolean type), string (String type)
Composite type: array (array), object (object)
Special type: null (empty), resource (resource)
The above is the detailed content of What types of php variables are there?. For more information, please follow other related articles on the PHP Chinese website!