Skip to Content
Modern PHP
book

Modern PHP

by Josh Lockhart
February 2015
Intermediate to advanced
268 pages
5h 51m
English
O'Reilly Media, Inc.
Content preview from Modern PHP

Chapter 2. Features

The modern PHP language has exciting new features. Many of these features will be new to PHP programmers upgrading from earlier versions, and they’ll be a nice surprise to programmers migrating to PHP from another language. These new features make the PHP language a powerful platform and provide a pleasant experience for building web applications and command-line tools.

Some of these features aren’t essential, but they do make our lives easier. Some features, however, are essential. Namespaces, for example, are a cornerstone of modern PHP standards and enable development practices that modern PHP developers take for granted (e.g., autoloading). I’ll introduce each new feature, explain why it is useful, and show you how to implement it in your own projects.

Tip

I encourage you to follow along on your own computer. You can find all of the code examples in the companion GitHub repository.

Namespaces

If there is one modern PHP feature I want you to know, it is namespaces. Introduced in PHP 5.3.0, namespaces are an important tool that organizes PHP code into a virtual hierarchy, comparable to your operating system’s filesystem directory structure. Each modern PHP component and framework organizes its code beneath its own globally unique vendor namespace so that it does not conflict with, or lay claim to, common class names used by other vendors.

Note

Don’t you hate it when you walk into a coffee shop and this one obnoxious person has a mess of books and cables ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Domain-Driven Design in PHP

Domain-Driven Design in PHP

Keyvan Akbary, Carlos Buenosvinos, Christian Soronellas
Learning PHP

Learning PHP

David Sklar
Clean Code in PHP

Clean Code in PHP

Carsten Windler, Alexandre Daubois

Publisher Resources

ISBN: 9781491905173Errata PageSupplemental Content