Michigan web site - 113Chapter 6Control and Functions{ print(chr(ord( A ) + $count)); $count
113Chapter 6Control and Functions{ print(chr(ord( A ) + $count)); $count = $count + 1; } print(
Now I know $count letters
); } $count = 0; SayMyABCs3(); $count = $count + 1; print( Now I ve made $count function call(s).
); SayMyABCs3(); $count = $count + 1; print( Now I ve made $count function call(s).
); This memory-enhanced version gives us the following output: ABCDEFGHIJNow I know 10 lettersNow I ve made 1 function call(s). KLMNOPQRSTNow I know 20 lettersNow I ve made 2 function call(s). The static keyword allows for an initial assignment, which has an effect only if the functionhas not been called before. The first time SayMyABCs3()executes, the local version of$countis set to zero. The second time the function is called, it has the value it had at the end of the last execution, so we are able to pick up our studies where we left off. Notice thatchanges to $countoutside the function still have no effect on the local value. ExceptionsNew to PHP5 is the Exceptionclass. We ve already seen some fairly primitive error handlingin the form of die(), and you might well imagine the custom error handling possibilitiesimplied by the combination of control structures and basic use of print()or printf() commands (more on this in Chapter 26). However, in prior versions of PHP, a chief complaintwas the lack of standardized means for handling errors, and separating that means from theapplication code itself. Enter Exceptions. Exceptions use the try, catchsyntax similar to Java or Python, although programmersusing those languages will note the absence of finally. Let s start with a simple example that has no error handling at all: function print_header($title, $keywords, $description) { print(
In case you need quality webspace to host and run your web applications, try our personal web hosting services.