- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathref.php
More file actions
Latest commit
36 lines (27 loc) · 572 Bytes
/
Copy pathref.php
File metadata and controls
36 lines (27 loc) · 572 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
<?php
/* Using references */
$arr = [4, 2, 1, 7, 4, 6];
functionsortAndReturnSum(&$arr)
{
sort($arr);
returnarray_sum($arr);
}
$sum = sortAndReturnSum($arr);
print_r($arr);
echo"sum: " . $sum . "\n";
/* Using globals */
global$arr2;
$arr2 = [4, 2, 1, 7, 4, 6];
functionsortAndReturnSumGlob($arr2)
{
global$arr2;
sort($arr2);
returnarray_sum($arr2);
}
$sum2 = sortAndReturnSumGlob($arr);
print_r($arr2);
echo"sum: " . $sum2 . "\n";
/* Using namspaces */
// namespace test;
// \test\$arr3 = [4, 2, 1, 7, 4, 6];
// var_dump(\test\$arr3);