Hướng dẫn which is not a php data type? - đó không phải là kiểu dữ liệu php?

Các loại dữ liệu PHP được sử dụng để chứa các loại dữ liệu hoặc giá trị khác nhau. PHP hỗ trợ 8 loại dữ liệu nguyên thủy có thể được phân loại thêm theo 3 loại:

  1. Các loại vô hướng (được xác định trước)
  2. Các loại hỗn hợp (do người dùng định nghĩa)
  3. Các loại đặc biệt

Kiểu dữ liệu PHP: Các loại vô hướng

Nó chỉ giữ giá trị đơn. Có 4 loại dữ liệu vô hướng trong PHP.

  1. boolean
  2. Số nguyên
  3. float
  4. sợi dây

Các loại dữ liệu PHP: Các loại hợp chất

Nó có thể giữ nhiều giá trị. Có 2 loại dữ liệu hỗn hợp trong PHP.

  1. mảng
  2. sự vật

Kiểu dữ liệu PHP: Các loại đặc biệt

Có 2 loại dữ liệu đặc biệt trong PHP.

  1. nguồn
  2. VÔ GIÁ TRỊ

PHP Boolean

Booleans là loại dữ liệu đơn giản nhất hoạt động như Switch. Nó chỉ giữ hai giá trị: true (1) hoặc false (0). Nó thường được sử dụng với các tuyên bố có điều kiện. Nếu điều kiện là chính xác, nó sẽ trả về đúng nếu không sai.TRUE (1) or FALSE (0). It is often used with conditional statements. If the condition is correct, it returns TRUE otherwise FALSE.

Example:

Output:

Số nguyên PHP

Số nguyên có nghĩa là dữ liệu số với dấu âm hoặc dương. Nó chỉ chứa toàn bộ số, tức là, các số không có phần phân số hoặc số thập phân.

Quy tắc cho số nguyên:

  • Một số nguyên có thể là tích cực hoặc âm.
  • Một số nguyên không được chứa dấu thập phân.
  • Số nguyên có thể là thập phân (cơ sở 10), octal (cơ sở 8) hoặc thập lục phân (cơ sở 16).
  • Phạm vi của một số nguyên phải nằm trong khoảng từ 2.147.483.648 đến 2.147.483.647, tức là, -2^31 đến 2^31.

Example:

Output:

Decimal number: 34
Octal number: 163
HexaDecimal number: 69

Php float

Một số điểm nổi là một số có điểm thập phân. Không giống như số nguyên, nó có thể giữ các số có điểm phân số hoặc thập phân, bao gồm một dấu hiệu âm hoặc dương.

Example:

Output:

Addition of floating numbers: 73.812

Chuỗi PHP

Một chuỗi là một loại dữ liệu không phải là số. Nó chứa các chữ cái hoặc bất kỳ bảng chữ cái, số và thậm chí các ký tự đặc biệt.

Giá trị chuỗi phải được đặt trong hoặc trong các trích dẫn đơn hoặc trong các trích dẫn kép. Nhưng cả hai đều được đối xử khác nhau. Để làm rõ điều này, xem ví dụ dưới đây:single quotes or in double quotes. But both are treated differently. To clarify this, see the example below:

Example:

Output:

Hello Javatpoint
Hello $company

Mảng PHP

Một mảng là một loại dữ liệu hỗn hợp. Nó có thể lưu trữ nhiều giá trị của cùng một loại dữ liệu trong một biến duy nhất.

Example:

Output:

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM

Bạn sẽ tìm hiểu thêm về mảng trong các chương sau của hướng dẫn này.

Đối tượng PHP

Đối tượng là trường hợp của các lớp do người dùng xác định có thể lưu trữ cả giá trị và hàm. Họ phải được tuyên bố rõ ràng.

Example:

Output:

Bike Model: Royal Enfield

Đây là một chủ đề nâng cao của PHP, mà chúng tôi sẽ thảo luận chi tiết sau.

Tài nguyên PHP

Tài nguyên không phải là loại dữ liệu chính xác trong PHP. Về cơ bản, chúng được sử dụng để lưu trữ một số cuộc gọi chức năng hoặc tham chiếu đến tài nguyên PHP bên ngoài. Ví dụ - một cuộc gọi cơ sở dữ liệu. Nó là một tài nguyên bên ngoài.For example - a database call. It is an external resource.

Đây là một chủ đề nâng cao của PHP, vì vậy chúng tôi sẽ thảo luận chi tiết sau với các ví dụ.

PHP null

Null là một loại dữ liệu đặc biệt chỉ có một giá trị: NULL. Có một quy ước viết nó bằng chữ in hoa vì nó nhạy cảm với trường hợp.NULL. There is a convention of writing it in capital letters as it is case sensitive.

Loại đặc biệt của loại dữ liệu null xác định một biến không có giá trị.

Example:

Output:


Các loại dữ liệu xác định loại dữ liệu mà một biến có thể lưu trữ. PHP cho phép tám loại dữ liệu khác nhau. Tất cả chúng được thảo luận dưới đây. Có các loại dữ liệu đặc biệt được xác định trước, do người dùng định nghĩa và người dùng.

Các loại dữ liệu được xác định trước là:

  • Boolean
  • Số nguyên
  • Kép
  • Sợi dây

Các loại dữ liệu do người dùng xác định (hợp chất) là:

  • Mảng
  • Các đối tượng

Các loại dữ liệu đặc biệt là:

  • VÔ GIÁ TRỊ
  • nguồn

Năm đầu tiên được gọi là các loại dữ liệu đơn giản và ba loại cuối cùng là các loại dữ liệu hỗn hợp: & nbsp; & nbsp;
 

1. Số nguyên: Số nguyên chỉ chứa các số toàn bộ bao gồm các số dương và số âm, tức là, các số không có phần phân số hoặc dấu thập phân. Chúng có thể là thập phân (cơ sở 10), bát phân (cơ sở 8) hoặc thập lục phân (cơ sở 16). Cơ sở mặc định là thập phân (cơ sở 10). Các số nguyên bát phân có thể được khai báo với hàng đầu 0 và thập lục phân có thể được khai báo với hàng đầu 0x. Phạm vi số nguyên phải nằm trong khoảng -2^31 đến 2^31. & nbsp;: Integers hold only whole numbers including positive and negative numbers, i.e., numbers without fractional part or decimal point. They can be decimal (base 10), octal (base 8), or hexadecimal (base 16). The default base is decimal (base 10). The octal integers can be declared with leading 0 and the hexadecimal can be declared with leading 0x. The range of integers must lie between -2^31 to 2^31. 

Example:  

PHP

Addition of floating numbers: 73.812
0

Addition of floating numbers: 73.812
1
Addition of floating numbers: 73.812
2

Addition of floating numbers: 73.812
3
Addition of floating numbers: 73.812
4

Addition of floating numbers: 73.812
5
Addition of floating numbers: 73.812
6

Addition of floating numbers: 73.812
7
Addition of floating numbers: 73.812
8

Addition of floating numbers: 73.812
9
Hello Javatpoint
Hello $company
0
Addition of floating numbers: 73.812
1
Hello Javatpoint
Hello $company
2
Addition of floating numbers: 73.812
3
Hello Javatpoint
Hello $company
4

Hello Javatpoint
Hello $company
5
Addition of floating numbers: 73.812
9
Hello Javatpoint
Hello $company
4

Hello Javatpoint
Hello $company
5
Hello Javatpoint
Hello $company
9
Hello Javatpoint
Hello $company
4

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
1
Addition of floating numbers: 73.812
9
array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
3

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
4

2. Double: Có thể giữ các số chứa các phần phân số hoặc thập phân bao gồm số dương và số âm hoặc một số ở dạng hàm mũ. Theo mặc định, các biến thêm một số lượng tối thiểu các vị trí thập phân. Kiểu dữ liệu kép giống như một chiếc phao như số điểm nổi hoặc số thực.: Can hold numbers containing fractional or decimal parts including positive and negative numbers or a number in exponential form. By default, the variables add a minimum number of decimal places. The Double data type is the same as a float as floating-point numbers or real numbers.

Example: 

PHP

Addition of floating numbers: 73.812
0

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
6
array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
7

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
8
array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
9

Addition of floating numbers: 73.812
9
Hello Javatpoint
Hello $company
0
array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
6
Hello Javatpoint
Hello $company
2
array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
8
Hello Javatpoint
Hello $company
4

Hello Javatpoint
Hello $company
5
Addition of floating numbers: 73.812
9
Hello Javatpoint
Hello $company
4

Hello Javatpoint
Hello $company
5
Hello Javatpoint
Hello $company
9
Hello Javatpoint
Hello $company
4

2. Double: Có thể giữ các số chứa các phần phân số hoặc thập phân bao gồm số dương và số âm hoặc một số ở dạng hàm mũ. Theo mặc định, các biến thêm một số lượng tối thiểu các vị trí thập phân. Kiểu dữ liệu kép giống như một chiếc phao như số điểm nổi hoặc số thực.

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
4

Đầu ra

705.11

float(705.11)

7. NULL: Đây là những loại biến đặc biệt chỉ có thể chứa một giá trị, tức là null. Chúng tôi tuân theo quy ước viết nó ở dạng vốn, nhưng nó nhạy cảm với trường hợp. Nếu một biến được tạo mà không có giá trị hoặc không có giá trị, nó sẽ tự động được gán giá trị null. Nó được viết bằng chữ in hoa.: Hold letters or any alphabets, even numbers are included. These are written within double quotes during declaration. The strings can also be written within single quotes, but they will be treated differently while printing variables. To clarify this look at the example below. 
 

Example: 

PHP

Ví dụ: & nbsp;

Addition of floating numbers: 73.812
50
Addition of floating numbers: 73.812
51

Hello Javatpoint
Hello $company
5
The name of the Geek is Krishna 
The name of the geek is $name 

string(7) "Krishna"
2
Hello Javatpoint
Hello $company
4

Hello Javatpoint
Hello $company
5
The name of the Geek is Krishna 
The name of the geek is $name 

string(7) "Krishna"
5
Hello Javatpoint
Hello $company
4

Hello Javatpoint
Hello $company
5
Hello Javatpoint
Hello $company
9
Hello Javatpoint
Hello $company
4

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
1
705.11

float(705.11)
7
array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
3

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
4

Đầu ra

The name of the Geek is Krishna 
The name of the geek is $name 

string(7) "Krishna"

4. Boolean: Các loại dữ liệu Boolean được sử dụng trong thử nghiệm có điều kiện. Chỉ giữ hai giá trị, đúng (1) hoặc sai (0). Các sự kiện thành công sẽ trả về các sự kiện đúng và không thành công trở lại sai. Giá trị loại NULL cũng được coi là sai trong boolean. Ngoài NULL, 0 cũng được coi là sai trong Boolean. Nếu một chuỗi trống thì nó cũng được coi là sai trong kiểu dữ liệu boolean. & Nbsp;: Boolean data types are used in conditional testing. Hold only two values, either TRUE(1) or FALSE(0). Successful events will return true and unsuccessful events return false. NULL type values are also treated as false in Boolean. Apart from NULL, 0 is also considered false in boolean. If a string is empty then it is also considered false in boolean data type. 

Ví dụ: & nbsp; & nbsp;   

PHP

Addition of floating numbers: 73.812
0

This condition is TRUE
5
This condition is TRUE
6

This condition is TRUE
7
Hello Javatpoint
Hello $company
5
This condition is TRUE
9
Hello Javatpoint
Hello $company
4

This condition is TRUE
5
First Element: 10
Second Element: 20
Third Element: 30

array(3) {
  [0]=>
  int(10)
  [1]=>
  int(20)
  [2]=>
  int(30)
}
2

This condition is TRUE
7
Hello Javatpoint
Hello $company
5
First Element: 10
Second Element: 20
Third Element: 30

array(3) {
  [0]=>
  int(10)
  [1]=>
  int(20)
  [2]=>
  int(30)
}
5
Hello Javatpoint
Hello $company
4

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
4

Đầu ra

This condition is TRUE

4. Boolean: Các loại dữ liệu Boolean được sử dụng trong thử nghiệm có điều kiện. Chỉ giữ hai giá trị, đúng (1) hoặc sai (0). Các sự kiện thành công sẽ trả về các sự kiện đúng và không thành công trở lại sai. Giá trị loại NULL cũng được coi là sai trong boolean. Ngoài NULL, 0 cũng được coi là sai trong Boolean. Nếu một chuỗi trống thì nó cũng được coi là sai trong kiểu dữ liệu boolean. & Nbsp;: Array is a compound data type that can store multiple values of the same data type. Below is an example of an array of integers. It combines a series of data that are related together.
  

PHP

Addition of floating numbers: 73.812
0

This condition is TRUE
7
Hello Javatpoint
Hello $company
5
This condition is TRUE
9
Hello Javatpoint
Hello $company
4

This condition is TRUE
7
Hello Javatpoint
Hello $company
5
First Element: 10
Second Element: 20
Third Element: 30

array(3) {
  [0]=>
  int(10)
  [1]=>
  int(20)
  [2]=>
  int(30)
}
5
Hello Javatpoint
Hello $company
4

5. Mảng: Mảng là một loại dữ liệu ghép có thể lưu trữ nhiều giá trị của cùng một loại dữ liệu. Dưới đây là một ví dụ về một loạt các số nguyên. Nó kết hợp một loạt dữ liệu có liên quan với nhau. & Nbsp; & nbsp;

First Element: 10
Second Element: 20
Third Element: 30

array(3) {
  [0]=>
  int(10)
  [1]=>
  int(20)
  [2]=>
  int(30)
}
9
Hello Javatpoint
Hello $company
0
This is an example of Object Data Type!
1

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
1
First Element: 10
Second Element: 20
Third Element: 30

array(3) {
  [0]=>
  int(10)
  [1]=>
  int(20)
  [2]=>
  int(30)
}
9
Addition of floating numbers: 73.812
04

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
4

Đầu ra

First Element: 10
Second Element: 20
Third Element: 30

array(3) {
  [0]=>
  int(10)
  [1]=>
  int(20)
  [2]=>
  int(30)
}

4. Boolean: Các loại dữ liệu Boolean được sử dụng trong thử nghiệm có điều kiện. Chỉ giữ hai giá trị, đúng (1) hoặc sai (0). Các sự kiện thành công sẽ trả về các sự kiện đúng và không thành công trở lại sai. Giá trị loại NULL cũng được coi là sai trong boolean. Ngoài NULL, 0 cũng được coi là sai trong Boolean. Nếu một chuỗi trống thì nó cũng được coi là sai trong kiểu dữ liệu boolean. & Nbsp;
 

Ví dụ: & nbsp; & nbsp;: Objects are defined as instances of user-defined classes that can hold both values and functions and information for data processing specific to the class. This is an advanced topic and will be discussed in detail in further articles. When the objects are created, they inherit all the properties and behaviours from the class, having different values for all the properties.

PHP

PHP

Addition of floating numbers: 73.812
0

This condition is TRUE
7
Hello Javatpoint
Hello $company
5
This condition is TRUE
9
Hello Javatpoint
Hello $company
4

This condition is TRUE
7
Hello Javatpoint
Hello $company
5
First Element: 10
Second Element: 20
Third Element: 30

array(3) {
  [0]=>
  int(10)
  [1]=>
  int(20)
  [2]=>
  int(30)
}
5
Hello Javatpoint
Hello $company
4

5. Mảng: Mảng là một loại dữ liệu ghép có thể lưu trữ nhiều giá trị của cùng một loại dữ liệu. Dưới đây là một ví dụ về một loạt các số nguyên. Nó kết hợp một loạt dữ liệu có liên quan với nhau. & Nbsp; & nbsp;

This condition is TRUE
7
Addition of floating numbers: 73.812
19
Addition of floating numbers: 73.812
20
Addition of floating numbers: 73.812
11
Hello Javatpoint
Hello $company
4

Addition of floating numbers: 73.812
09
Addition of floating numbers: 73.812
24

First Element: 10
Second Element: 20
Third Element: 30

array(3) {
  [0]=>
  int(10)
  [1]=>
  int(20)
  [2]=>
  int(30)
}
9
Hello Javatpoint
Hello $company
0
This is an example of Object Data Type!
1

Hello Javatpoint
Hello $company
5
This is an example of Object Data Type!
4
Hello Javatpoint
Hello $company
4

Addition of floating numbers: 73.812
09
Addition of floating numbers: 73.812
24

Addition of floating numbers: 73.812
24

Hello Javatpoint
Hello $company
5
This is an example of Object Data Type!
7
Hello Javatpoint
Hello $company
4

Hello Javatpoint
Hello $company
5
Addition of floating numbers: 73.812
00
Hello Javatpoint
Hello $company
4

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
4

Đầu ra

This is an example of Object Data Type!

4. Boolean: Các loại dữ liệu Boolean được sử dụng trong thử nghiệm có điều kiện. Chỉ giữ hai giá trị, đúng (1) hoặc sai (0). Các sự kiện thành công sẽ trả về các sự kiện đúng và không thành công trở lại sai. Giá trị loại NULL cũng được coi là sai trong boolean. Ngoài NULL, 0 cũng được coi là sai trong Boolean. Nếu một chuỗi trống thì nó cũng được coi là sai trong kiểu dữ liệu boolean. & Nbsp; These are special types of variables that can hold only one value i.e., NULL. We follow the convention of writing it in capital form, but it’s case-sensitive. If a variable is created without a value or no value, it is automatically assigned a value of NULL. It is written in capital letters.

Ví dụ: & nbsp; & nbsp; 

PHP

Addition of floating numbers: 73.812
0

This condition is TRUE
7
Hello Javatpoint
Hello $company
5
This condition is TRUE
9
Hello Javatpoint
Hello $company
4

This condition is TRUE
7
Hello Javatpoint
Hello $company
5
First Element: 10
Second Element: 20
Third Element: 30

array(3) {
  [0]=>
  int(10)
  [1]=>
  int(20)
  [2]=>
  int(30)
}
5
Hello Javatpoint
Hello $company
4

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
1
Addition of floating numbers: 73.812
50
Addition of floating numbers: 73.812
04

array(3) { [0]=> string(13) "Royal Enfield" [1]=> string(6) "Yamaha" [2]=> string(3) "KTM" }
Array Element1: Royal Enfield
Array Element2: Yamaha
Array Element3: KTM
4

5. Mảng: Mảng là một loại dữ liệu ghép có thể lưu trữ nhiều giá trị của cùng một loại dữ liệu. Dưới đây là một ví dụ về một loạt các số nguyên. Nó kết hợp một loạt dữ liệu có liên quan với nhau. & Nbsp; & nbsp;: Resources in PHP are not an exact data type. These are basically used to store references to some function call or to external PHP resources. For example, consider a database call. This is an external resource. Resource variables hold special handles for files and database connections.
We will discuss resources in detail in further articles.

Note:  

  • First Element: 10
    Second Element: 20
    Third Element: 30
    
    array(3) {
      [0]=>
      int(10)
      [1]=>
      int(20)
      [2]=>
      int(30)
    }
    9
    Hello Javatpoint
    Hello $company
    
    0
    This is an example of Object Data Type!
    1 var_dump() function which dumps information about a variable. 
  • Hello Javatpoint
    Hello $company
    
    5
    This is an example of Object Data Type!
    4
    Hello Javatpoint
    Hello $company
    
    4

Hello Javatpoint
Hello $company
5
This is an example of Object Data Type!
7
Hello Javatpoint
Hello $company
4Chinmoy Lenka. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to . See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above.
 


Các loại dữ liệu PHP là gì?

Kiểu dữ liệu PHP..
String..
Integer..
Float (số điểm nổi - còn được gọi là gấp đôi).
Boolean..
Array..
Object..
Resource..

Cái nào không phải là kiểu dữ liệu?

mảng không phải là một loại dữ liệu. is not a data type.

Loại dữ liệu nào trong PHP MCQ?

PHP có ba loại phạm vi biến: biến cục bộ.Biến toàn cầu.Biến tĩnh.Local variable. Global variable. Static variable.

Có bao nhiêu loại dữ liệu khác nhau có sẵn trong PHP?

PHP hỗ trợ 8 loại dữ liệu nguyên thủy có thể được phân loại thêm theo 3 loại: các loại hợp chất (được xác định trước) (định nghĩa người dùng) Các loại đặc biệt.8 primitive data types that can be categorized further in 3 types: Scalar Types (predefined) Compound Types (user-defined) Special Types.