Home > Backend Development > PHP Problem > What types of php variables are there?

What types of php variables are there?

(*-*)浩
Release: 2023-02-26 06:38:01
Original
3119 people have browsed it

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;
?>
Copy after login

Rules for defining variables

Variable names are case-sensitive

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template