-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.php
More file actions
60 lines (46 loc) · 698 Bytes
/
function.php
File metadata and controls
60 lines (46 loc) · 698 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
$a = 5;
$b = 2;
$y;
function myTestFunction()
{
global $a;
$GLOBALS['y'] = $GLOBALS['a'] + $GLOBALS['b'];
echo $a;
echo '<br />';
}
myTestFunction();
echo $y, '<br />';
function myTestFunction2()
{
static $x = 1;
echo $x;
$x++;
}
myTestFunction2();
myTestFunction2();
myTestFunction2();
myTestFunction2();
function defaultValue(string $color = 'green')
{
echo '<br />';
echo $color;
}
defaultValue();
// override
defaultValue('red');
function argByReference(int &$num1)
{
echo '<br />';
$num1 += 5;
}
$num = 10;
argByReference($num);
echo $num;
// ADVANCE
function returnString(int $num1): int
{
return $num1;
}
echo '<br />';
var_dump(returnString(4));