lecture24

lecture24 - PIC 40A Lecture 24: PHP Functions, Variables,...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
PIC 40A Lecture 24: PHP Functions, Variables, Arrays
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
PHP functions Syntax function name($param1,$param2,. .) { // write function body here }
Background image of page 2
Notes on PHP functions • function overloading is not allowed • functions cannot be redefined • function definitions can be nested as in JavaScript • function names are not case sensitive •u s e o f return statement is optional (can return no value)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
PHP Function Parameters formal parameters are in the function prototype and must be variable names actual parameters are in the function call and can be any expression • the number of formal parameters need not match the number of actual parameters • excess formal parameters are NULL • excess actual parameters are ignored
Background image of page 4
Parameter Example function display( $formal_parameter ){ print($formal_parameter); } $actual_parameter = "message"; display( $actual_parameter );
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Parameter Passing • By default, PHP passes parameters by value • (i.e. the values of the formal parameters in the function definition are not copied into their actual parameter counterparts in the function call)
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/15/2010 for the course PIC 40A taught by Professor Ouellette during the Winter '10 term at UCLA.

Page1 / 19

lecture24 - PIC 40A Lecture 24: PHP Functions, Variables,...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online