Home > Backend Development > PHP Problem > What is enum type in PHP? set type?

What is enum type in PHP? set type?

慕斯
Release: 2023-03-10 22:02:01
Original
2235 people have browsed it

We have learned so much about PHP in PHP. I don’t know how much you know about the types of PHP. I believe that a large number of people will not know this part of the knowledge. So don’t worry, this article will lead you to learn more about it. Understand this content deeply.

Related recommendations: Learn about encapsulating watermark functions in PHP in one minute

enum type:

Single option string data type. It is very suitable for storing "single option values" in form interfaces;

When it is set, it needs to be given "a few fixed options", and then when it is stored, only one of the values ​​is stored. :

The form is as follows:

enum("Option 1", "Option 2", "Option 3", ... );

Actual internal:

These string option values ​​correspond to the following numeric values: 1, 2, 3, 4, s,... up to 65535 options;

Writing data format:

You can use the option string itself or the corresponding number;

set type:

Multi-option string data type. It is very suitable for storing "multiple option values" in the form interface;

When it is set, it also needs to be given "a few fixed options", and then when it is stored, several of them can be stored Value;

The format is as follows:

set("Option 1","Option 2","Option 3", ... );

Actual internal:

These string option values ​​correspond to the following numerical values: 1, 2, 4, 8, 16,... up to 64 options;

create table enum_ set (
id int auto increment primary key,
sex enum(' 男', '女'),
fav set(' 篮球','排球
'足求’,'中国足球','台球')
);
Copy after login
<?php
#插入数据演示:
insert into enum_set (id, sex, fav) values(null, &#39;男&#39;, &#39; 篮球&#39;);
insert into enum_set (id, sex, fav) values (nu1l,1, 1);
#下面演示多选项的数据输入情形:
insert into enum_set (id,sex, fav) values(null, &#39;男&#39;, &#39;篮球,排球,台球&#39;);
insert into enum_set (id, sex, fav) values(null, &#39;女&#39;, 19);
#这里,19解释为: 1+2+16, 也就对应篮球,排球和台球
#这里,19不可能解释为: 15+4或13 + 6或其他。..|
Copy after login

text type:

It becomes the "long text" character type. Typically, the data stored there does not occupy the data capacity limit in the table. It can store up to 65535 zero characters.

Other similar character types: smalltext, tinyext, longtext.

Others (understand)↓

binary type:

definite Long binary string type, which stores binary values;

varbinary type: variable-length binary string type, which stores binary values:

blob type:

Binary data type still stores binary values, but it is suitable for storing "pictures", "other files", etc.

Related learning video sharing: php video tutorial

The above is the detailed content of What is enum type in PHP? set type?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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