-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03_data_types.php
43 lines (37 loc) · 1.1 KB
/
03_data_types.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* PHP supports the following data types:
* String: Sequence of characters, enclosed within single quotes ('') or double quotes ("").
* Integer: Whole numbers without decimal points.
* Float /double: Numbers with decimal points or in exponential form.
* Boolean: Represents true or false values.
* Array: Collection of key-value pairs, where each key is associated with a value.
* Object: Instance of a class, containing properties and methods.
* NULL: Represents a variable with no value or an unset value.
* Resource: Special variable holding a reference to an external resource, such as a file or database connection.
*/
$string = 'PHP'; // string(3) "PHP"
$integer = 1; // int(1)
$float = 99.99; // float(99.99)
$boolean = true; //bool(true)
$even_numbers=[2,4,6,8];
$object = (object) ['key' => 'value'];
$null = NULL; // NULL
// $resource = fopen("example.txt", "r");
var_dump($null, $string, $integer, $float, $boolean, $even_numbers, $object);
/**
array(4) {
[0]=>
int(2)
[1]=>
int(4)
[2]=>
int(6)
[3]=>
int(8)
}
object(stdClass)#1 (1) {
["key"]=>
string(5) "value"
}
*/