Function Arguments - PHP - P36
Going over Function Parameters and passing arguments to functions. Do you know what the difference is between a parameter and an argument?
An argument is the data that we pass to the function when we invoke the function. Let's look at the anatomy of the function a little closer.
function function_name( $parameter_1, $parameter_2, ... ) {
// function body
}
We looked at the overall function declaration in the last video. The only new concept should be the parameters that are declared between the parentheses. You may have noticed that earlier I was talking about arguments and now I'm talking about parameters. When we call the function, we pass arguments; when we declare a function, we declare parameters. Quite a few programmers get that confused.
Functions can have multiple parameters. Each parameter is separated by a comma. The parameter naming convention is identical to the variable naming convention.
When passing arguments to the function, just envision that you're assigning values to the parameters.
A function can be declared with some parameters containing default values and others without. The default-value-parameters will have to be pushed to the end of the declaration. Your required parameters will have to appear in the beginning. When working with multiple parameters, you have to provide arguments in the order that the parameters were declared. If the default parameters were in the beginning, and you skipped over them, how would PHP know what you skipped over? It just sees values coming in. There are programming languages where you can explicitly assign arguments to parameters when invoking functions, but PHP is not one of those languages. As a matter of fact, most programming languages follow the same rules as PHP does.
function func_name($p_1, $p_2, $p_3 = "Default") {
// function body
}
Read the full article on my website
https://www.dinocajic.com/php-function-arguments/
Code for this tutorial
https://github.com/dinocajic/php-7-youtube-tutorials/blob/master/36%20Function%20Arguments.php
Full Code
https://github.com/dinocajic/php-7-youtube-tutorials
PHP Playlist
https://www.youtube.com/playlist?list=PLbhJy0VhR6SAmoneYvF6Y_axQJKg7i50M
--
Dino Cajic
Author and Head of IT
Homepage: https://www.dinocajic.com
GitHub: https://github.com/dinocajic
Medium: https://medium.com/@dinocajic
Instagram: https://www.instagram.com/think.dino
LinkedIn: https://www.linkedin.com/in/dinocajic/
Twitter: https://twitter.com/dino_cajic
My Books
An Illustrative Introduction to Algorithms
https://www.amazon.com/dp/1686863268
Laravel Excel: Using Laravel to Import Data
https://amzn.to/4925ylw
Code Along With Me - PHP: From Basic to Advanced PHP Techniques
https://amzn.to/3M6tlGN
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Function Arguments - PHP - P36», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.