Namespaces - PHP - P68
Namespaces are used throughout numerous programming languages. If you’re familiar with Java, you might have heard of the term package. A package is a namespace in Java. The package allows the developer to group similar code together. In the simplest sense, a package is a folder or a directory.
Namespaces give the programmer the ability to reuse class names in different contexts. The easiest way to look at namespaces from a non-programming perspective is through the convention on how people are named. My parents gave me the first name Dino. Although there are probably thousands of Dino’s in the world, what defines me as part of my family’s namespace is the last name Cajic. So how does this translate to programming and to PHP? You can have two files with the same name, but they cannot be in the same directory. Why would you even care about this? You could just avoid placing files with the same name or same class name in the same directory.
If you work on larger projects where you get 3rd party code, there’s a good chance that you’re going to have some naming conflict. How do you solve this? Do you create separate directories for everything and place files into those directories like that? What if you have frameworks that demand that you place specific types of code into specific directories? What if you’re autoloading your classes? Namespaces solve this with virtual directories. You can have two files, with exactly the same class name, but with different virtual directories, and PHP will treat them separately. We will be looking at defining namespaces, and sub-namespaces in the next couple of tutorials.
Read the full article on my website
https://www.dinocajic.com/php-namespaces/
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, чтобы посмотреть онлайн «Namespaces - PHP - P68», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.