Download presentation
Presentation is loading. Please wait.
1
Creating Dynamic Web Sites Part 3
Chapter 3 Creating Dynamic Web Sites Part 3
2
functions function function_name( ){ // function code. }
3
Reasons for a function To associate repeated code with one function call. To separate out sensitive or complicated processes from other code. To make common code bits easier to reuse.
4
index.php Script 3.7 on page 96
ch03\index.php
5
Function Arguments function print_hello($first, $last) { // Function code } print_hello(‘Andy’,’Dalton’); $surname=‘Dalton’; print_hello(‘Andy’,$surname);
6
calculator.php Script 3.8 on page 98-99
ch03\script_03_08\calculator.php
7
Default Argument Values
function greet($name, $msg=‘Hello’){ echo “$msg, $name”; } greet($username, $message); greet(‘Zoe’); greet(‘Sam’, ‘Good evening’);
8
calculator.php Script 3.9 on page 101-103
ch03\script_03_09\calculator.php
9
Return Values from a Function
function find_sign($month, $day ){ // function code. return $sign; } $mysign = find_sign(‘October’, 23); echo find_sign(‘October’, 23);
10
calculator.php Script 3.10 on page 105-107
ch03\calculator.php
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.