Type Hinting With The Iterable pseudo-type In PHP

As of PHP 7.1, you can now type hint your method/function arguments with the keyword iterable for handling arrays or even objects that implement the Traversable interface. Let’s create an example where we can convert any string to a slug. We’ll have 2 methods so that we can pass either a string or iterable data. […]

Read More »

Type Hinting Callable Functions in PHP

As of PHP 5.4, you can type hint your method arguments with the callable keyword allowing you to enforce the type of data that is passed via your arguments . Let’s look at an example where we create a Sort class, with a custom method that takes a callable function so that we can customize […]

Read More »

Setting Visibility For Your Class Constant’s In PHP

Now in PHP 7.1+, you can set different visibility modifiers for each of your class constants. The available visibility modifiers consist of public, protected, and private. Any constant’s within your class set to protected or private that you try to access directly outside of the class will throw a Fatal Error. Example Usage <?php class […]

Read More »

Using Anonymous Classes in PHP

As of PHP 7, you can now create quick throwaway objects for use within your projects. This can be especially useful for your automated tests, for instance, with allowing you to create quick implementations of your interfaces. Let’s review a Notifier interface that we may have. We can easily create a anonymous implementation by using […]

Read More »

Symmetric Array Destructuring in PHP

As of PHP 7.1, you can now use the shorthand array syntax to destructure your arrays for assignment. Previously you would have had to use a function like list, but now you can use the simple new array shorthand syntax. Let’s look at some examples. Basic Example <?php $names = [ 'Frank Perez', 'Carmella Osman', […]

Read More »

Using CSS Transitions

CSS transitions is the new preferred way of applying transitions to your elements compared to the old approach of using JavaScript. In this article, I’ll go through each of the transition properties available, and provide examples of how to use them. Below is a list of browser prefixes that you can use to enable backward […]

Read More »

Structuring Your Website With HTML 5 Semantics

Prior to HTML 5, there was no real markup to help explain the intent behind your HTML code. The goal of HTML 5 was to offer a more readable way of writing your code, so that any author that comes after you can have an easier time going through what you’ve created. So what are […]

Read More »