Functions
PHP has tons of built-in functions that do all sorts of things for you — string stuff, arrays, math, formatting, whatever. But the real power starts when you create your own functions, because now you can wrap a piece of logic, give it a name, and reuse it whenever you want.
A function is just a block of code that sits there quietly until you call it.
You define it with function name() { ... }, and then run it by writing name() later in the code. That’s all.
You can also give a function parameters — little pieces of data the function needs to do its job. You can have one, two, or however many you want. And PHP lets you set default values so you don’t need to pass a parameter every time.
Functions can also return a value. That’s the moment when a function stops and hands something back to whoever called it. Returning values is a big deal because it lets functions produce things instead of just printing them.
Then there’s the “pass by reference” thing. Normally PHP copies your variable into the function, so the original doesn’t change. But if you want the function to modify the original variable, you add & to the parameter. This is not something you use constantly, but it’s important to know it exists.
Variadic functions (...$x) are just a fancy way of saying “this function can take any number of arguments.” PHP will give you those arguments as an array.
Finally, PHP is loosely typed by default — it’s flexible and tries to guess what you meant. You can turn on strict types if you want the language to enforce that your parameters and return values are exactly the types you say they are. A lot of modern codebases use strict mode.
That’s basically the spirit of the lesson.