From the course: PHP Essential Training
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
Multiple return values - PHP Tutorial
From the course: PHP Essential Training
Multiple return values
- [Instructor] In the LASSO V, we learned how to return values from a function by using return. In this movie, we'll learn how to return multiple values from function. Well, sort of. You see, a function can only return a single value. That's a hard and faster rule about functions, that it returns only a single value. So what if we need to return more than one value? Well, first let's create an example, so we can look at the problem more closely. I'm going to open up basic doc html, and I'll do a Save As on that. And I'm going to call this functions, multiple returns, dot php. We'll give it the same name here, functions, Multiple Returns. All right, let's start with a new function, and this function I've called add underscore subt, short for subtract. So it's going to add and subtract two values, value one and value two. We're going to add them together, and then, we're going to subtract them. So we know how…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.