User Defined Functions - PHP - P35
Functions can be a difficult topic to grasp if you're a new programmer. I'm sure you were exposed to functions in math, but do you really understand what the term "function" means?
Think about an automotive plant:
- You bring the materials to the plant.
- You feed the plant with those materials.
- The plant takes the materials and somehow produces a car (we'll be focusing on this one).
The plant itself is the function. If you were an engineer, you would know what machinery needs to go inside of the plant in order to produce the car. Since we said that the plant is the function in this case, the internals of the plant are the internals of the function. The engineer that's implementing the internals of the plant literally translates to the programmer. The programmer knows how to construct the internals of the function.
Let's create our own virtual automotive plant (function). We'll start off easy. The engineer (programmer) will create the automotive plant (function) and the only thing that the plant will do is print out "I am an auto plant." Inside of the actual plant, this could be done by a printer or even some person writing down the words. In our virtual plant (function) we can use the echo statement to print out the words.
Before we can do that, we have to understand the anatomy of the user-defined function.
function function_name() {
// function body
}
The function starts with the keyword function followed by the function name. The function name can be any valid PHP name. Function names follow the same naming convention as variables: letter or underscore, followed by a series of letters, numbers, or underscores. The parentheses come next. In this case, there are no arguments that are passed to the function (we'll cover that later). After the parentheses, the opening curly brace signifies the opening of the function body. This is where you will place your echo statement (or any other code). Function bodies can have multiple lines of code; each line of code is separated with a semi-colon (go figure). Finally, the closing curly brace is used to signify the end of the function.
Read the full article on my website
https://www.dinocajic.com/php-user-defined-functions/
Code for this tutorial
https://github.com/dinocajic/php-7-youtube-tutorials/blob/master/35%20Functions.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, чтобы посмотреть онлайн «User Defined Functions - PHP - P35», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.