Download presentation
Presentation is loading. Please wait.
Published byEdmund Simpson Modified over 8 years ago
1
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 http://csweb.hh.nku.edu/csc301/frank/ch03/i ndex.php http://csweb.hh.nku.edu/csc301/frank/ch03/i ndex.php 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 http://csweb.hh.nku.edu/csc301/frank/ch03/s cript_03_08/calculator.php http://csweb.hh.nku.edu/csc301/frank/ch03/s cript_03_08/calculator.php 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 http://csweb.hh.nku.edu/csc301/frank/ch03/s cript_03_09/calculator.php http://csweb.hh.nku.edu/csc301/frank/ch03/s cript_03_09/calculator.php 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 http://csweb.hh.nku.edu/csc301/frank/ch03/c alculator.php http://csweb.hh.nku.edu/csc301/frank/ch03/c alculator.php ch03\calculator.php
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.