-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionArguments.php
More file actions
54 lines (38 loc) · 883 Bytes
/
Copy pathfunctionArguments.php
File metadata and controls
54 lines (38 loc) · 883 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
<?php
/**
* PHP can accept variables in function arguments by various methods.
*
* 1. Pass By Value - its the generic form.
*/
// 2. Pass By Reference
Function additionPBR(&$val) {
$val += 10;
}
$num = 5;
additionPBR($num);
echo "After Addition (Pass By Refenrence): ".$num;
/**
* Strict Variable - It defines if the function should typecast the variable
* while accepting arguments or not.
*
* This is set on top of the php code in the php start tag.
*
* The default value of Strict Variable is 0. meaning NOT Strict
*
* <?php strict_value=1
*
*/
function addWithoutStrict($a, $b) {
return $a + $b;
}
echo "<br><br>";
$c = addWithoutStrict(5, "6 Days");
echo "<br><br>";
echo $c;
/**
* Default values
* We can define while writing the function what default value should be assigned
* to the function if no values is passed.
*
*/
?>