Codelegance

php

A collection of 5 posts

php

When to use traits in PHP

Traits were introduced in PHP 5.4 on March 1st, 2012. Traits provide support for horizontal code reuse, but what is meant by horizontal reuse? Should we be using traits? This article explores

Paul Morris Paul Morris
coercion

Embracing coercion in PHP

Coercion is implicit typecasting for scalar types (integer, float, boolean and string). In this article we look at how we can use coercion as an elegant alternative to explicit typecasting. Coercing to integer

Paul Morris Paul Morris
regex

Ideal regex delimiters in PHP

We want to find regular expression delimiters that enable us to avoid inserting additional escape sequences into our patterns. This is ideal when we want to inject foreign patterns where we can't guarantee

Paul Morris Paul Morris
reference

New PHP 5 syntax reference

We briefly review the major new PHP language syntax introduced in each version since 5.3 – the version that birthed the features that paved the way for the prevailing PHP renaissance. Always Every

Paul Morris Paul Morris
array

Array merging in PHP

Correctly merging two arrays into a single array requires thinking about the type of data we have. Is our data flat or does it contain nested arrays? What should happen when both arrays

Paul Morris Paul Morris
Codelegance © 2025
Latest Posts