-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0206.php
More file actions
42 lines (34 loc) · 978 Bytes
/
0206.php
File metadata and controls
42 lines (34 loc) · 978 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
<?php
// echo phpinfo();
// declare (strict_types = 1);
ini_set('display_errors', 1); // Enable displaying errors in the browser
// // ini_set('display_startup_errors', 1); // Display errors on startup
error_reporting(E_ALL); // Report all errors (including notices)
function dummyFn($n): int
{
return "100"; //enbling string_type gives error
}
$value = dummyFn([1, 2, 3, 4, 5]);
var_dump($value);
$param = null;
$param ??= 120;
// this prints 120 but if we define $param as 20 then it gives 20 though we assigned it to 120 later on
var_dump($param);
$namedfn = function (int $n) use ($param) {
return $n + $param;
};
echo $namedfn(5);
$output = fn($n) => $n + $param;
echo $output(20);
$dummyAry = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function simpleFn(...$values)
{
var_dump(...$values);
return array_sum($values);
}
echo simpleFn(...$dummyAry);
function simpleFn2(...$allargu)
{
var_dump($allargu);
}
echo simpleFn2(10, $dummyAry, 'string', 4.5, 22);