-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask3.php
33 lines (27 loc) · 1.09 KB
/
task3.php
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
<?php
/**
* Author : Fabio Pinto
* Description of requirements:
* Using page 383 as a guide, as well as two sentences ("The dog ate my homework" and "I lied about
* that"), create two functions to illustrate the difference between an argument passed by value and an
* argument passed by reference. The outcome should look like the screenshot below.
**/
//Function that demonstrates passing arguments by reference
function byref(&$sentence) {
$sentence = 'I lied about that';
}
//Fucntion that demonstrates passing arguments by value
function byval($sentence) {
$sentence = 'I lied about that';
}
//Variable that will be passed to functions
$sentence = "The dog ate my homework";
//Construction and calling of functions to produce the desired output
echo '<u>Passsing by value</u></br>';
echo $sentence.' -> '; byval($sentence); echo $sentence.'</br>';
echo '</br><u>Passing by reference</u></br>';
echo $sentence.' -> '; byref($sentence); echo $sentence;
?>
</br><a href="index.html">Back...<a>
</br><iframe src="task3.txt" height="400" width="1200">
<p>Your browser does not support iframes.</p></iframe>