Join Kevin Skoglund for an in-depth discussion in this video Return values from a function, part of PHP Essential Training.
- [Instructor] All of our functions so far…having been using echo to send output to the user screen.…But more often than not we don't want that behavior.…Usually we'd like to get a result back from the function,…and then decide what to do with that result ourselves.…We might end up deciding to echo it to the screen,…but we might instead take that value,…and continue to use it to do more processing.…If it outputs from inside the function…then we lose that flexibility.…It's better to get back a value.…And for that, we need to understand…how to return values from a function.…Let's open up basic.html.…
We're going to do Save As on this.…And we're going to call this one functions_returnvalues.php.…Functions: Return Values.…So, let's just write a simple function here.…I've got an add function.…It takes two arguments, value 1 and value 2.…It adds them together, and assigns them to sum.…So let's just load this up in Firefox to begin with.…
Let's bring this up.…And instead of functions_arguments,…instead now we're going to be loading up returnvalues…
- 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.