I’ve finished reading about namespaces, and one of the most practical usages comes to mind.
If namespaces can be used to avoid collision with PHP’s core functions, I imagine that someone at some point has created a library that has faster core functions?
So for example, let’s say strtotime() is really slow in PHP. Someone says, “Oh, this is why it’s slow, it has all this functionality not everyone would need!” and releases a more efficient version of strtotime, which has no collision because of namespaces.
Does something like this exist? Have I completely missed the point of namespaces?
Edit: Thanks, folks.
The point of namespaces isn’t to avoid collisions with the PHP functions names, but with other PHP code. For example, if you’re using somebody else’s templating library that has a class named Template, then you can’t also create one yourself, even if that’s the best name for the class you’re building. With namespaces, all your class names exist in their own bubble. So, you can have \MyLibrary\Template and \OtherLibrary\Template.