-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinternal_functions.php
More file actions
44 lines (30 loc) · 937 Bytes
/
internal_functions.php
File metadata and controls
44 lines (30 loc) · 937 Bytes
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
44
<?php
// Create a function that checks if a variable is set or empty, and display "$variable_name is SET|EMPTY"
function check($var) {
if(empty($var) && isset($var)){
echo 'The variable is EMPTY and SET!';
} elseif(empty($var)) {
echo 'The variable is EMPTY!';
} else {
echo 'The variable is SET!';
}
echo PHP_EOL;
}
// TEST: If var $nothing is set, display '$nothing is SET'
$nothing = 'hello';
check($nothing);
// TEST: If var $nothing is empty, display '$nothing is EMPTY'
$nothing = null;
check($nothing);
// TEST: If var $something is set, display '$something is SET'
$something = '';
check($something);
// Serialize the array $array, and output the results
$array = array(1,2,3);
$array = serialize($array);
echo 'The serialized array is: ' . $array . PHP_EOL;
// Unserialize the array $array, and output the results
$array = unserialize($array);
echo 'The unserialized array is: ';
print_r($array);
?>