From the course: Learning PHP
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Namespacing
- [Illustrator] When you declare a variable, you can reassign values to it over and over again, even within the same scope. But when it comes to functions and classes, PHP isn't so open to that, and for good reason. Changing how a function works in the middle of a program would be like replacing your car engine with a bike pedals in the middle of the Daytona 500. That also means you need to be mindful of the code already written, especially if you're working within a larger framework with lots of contributing developers, something like WordPress or Laravel. You might not know all of the code that's written or could be written, and if your class or function names are not specific enough, you could unknowingly cause a site breaking errors. A more recent development in writing PHP is Namespacing. The idea here is that you might not have a class of functions, but it's common functionality that you don't want colliding with…
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.
Contents
-
-
-
-
-
-
-
-
Organizing your code2m 45s
-
(Locked)
Using include and require4m 43s
-
(Locked)
include_once and require_once2m 46s
-
(Locked)
Namespacing3m 29s
-
(Locked)
Challenge: Build a simple templating system for the provided markup32s
-
(Locked)
Solution: Build a simple templating system for the provided markup7m 18s
-
-
-
-
-