-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
54 lines (39 loc) · 1.17 KB
/
functions.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
$title = "Funtions";
include 'includes/header.php';
?>
<h1><center>Functions</center></h1>
<?php
/* Defining a Function */
function writeMessage(){
echo "You are really a nice person, Have a nice time!<br/>";
}
/* Calling a Function */
writeMessage();
echo '<hr>';
writeMessage();
/* Function with parameters */
function addFunction($num1, $num2){
$num = $num1 + $num2;
echo "The sum of $num1 and $num2 is: $num<br/>";
}
/* Pass by Reference - use ampersend in parameter */
function changeNum(&$num){
$num = $num + 10;
// $num+= 10;
}
function returnProduct($num1, $num2){
$prod = $num1 * $num2;
return $prod;
}
$num = 500;
addFunction(10, 32);
addFunction(10, $num);
addFunction('10', "50");
changeNum($num);
echo $num . '<br/>';
$return_value = returnProduct(10, 200);
echo $return_value . '<br/>';
echo '<hr>';
?>
<?php require 'includes/footer.php' ?>