All pages in tagged with #Methods


Make PHP More Useable - Returning Multiple Values from Functions

Use Golang inspired pattern to easily return multiple values from PHP functions.

Thursday Jul 16, 2015 — 2 minute read — 395 words

If you’ve ever used Go it’s hard to not find returning multiple values from functions conspicuously absent in other languages. In this case, we’ll look at a simple way to implement the same design pattern effectively in PHP. Why It’s Useful So why return multiple values from a function anyway? If you’ve never used Golang or a similar language which allows that, it may not be readily obvious. Most use-cases in Golang are centered around errors, so it’s very easy to check if a function encountered a error.

Read More