Join Kevin Skoglund for an in-depth discussion in this video Set default argument values, part of PHP Essential Training.
- [Instructor] We've already learned that the arguments…when you call a function must match the arguments…that were used to define the function.…If you define it with three arguments,…then you need to provide three arguments as input.…However there is a way around that,…by setting default argument values.…Let's see how.…So we'll open up basic.html,…and we'll call Save As on that,…and let's call this functions_default.php.…Functions default argument values.…
Alright so to start with,…let's write ourselves a little function.…And I'm going to call this function paint.…So function paint,…and let me just put the curly braces there,…and this paint is going to take a color as an argument.…The work that this function is going to do,…is we're going to return a string which is the color…of the room is and then we'll have our…curly braces with the color,…and then I'll put a period and a br tag at the end.…Followed by the semi colon.…
Okay?…So now we know how to call that, right?…We can simply say echo, paint and blue.…And let's bring that up in a window and check it out.…
- What is PHP?
- Embedding PHP code on a page
- Inserting code comments
- Variables, strings, arrays, and Booleans
- If, else, and elseif statements
- While and for loops
- User-defined functions
- Function arguments and return values
- Debugging and troubleshooting
Skill Level Beginner
MVC Frameworks for Building PHP Web Applicationswith Drew Falkman2h 57m Intermediate
1. PHP Overview
2. First Steps
3. Explore Data Types
4. Control Structures: Logical Expressions
5. Control Structures: Loops
6. User-Defined Functions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.