Functions
Try your had at creating your own PHP functions with these exercises. They span the very simplest functions to the more complex.
- #1: Simple Function
- Create a function to print the classic "Hello World!" to the browser.
- #2: Arguments and Return Values
- Create two versions of a function to calculate the area of a rectangle.
- #3: Arguments from User Input
- Rewrite the exercise from #2 to accept user input.
- #4: Function for HTML
- Write an array of months and their corresponding number of days, with a function to create option elements for a select field.
- #5: Variable Argument Number
- Two versions of a script revisiting weather conditions. Functions for HTML, and a function that can accept a string or array as argument.
- #6: Function That Calls Another
- Rewrite Functions Ex. #4 to expand the option function and call it in a new function that creates a select field.