O'Reilly logo

Functional PHP by Gilles Crettenand

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2.  Pure Functions, Referential Transparency, and Immutability

Those who have read the appendix about functional programming will have seen that it revolves around pure functions, or in other words, functions that only use their input to produce a result.

It might seem easy to determine whether a function is pure or not. It's just about checking that you don't call any global state, right? Sadly, it's not that simple. There are also multiple ways a function can produce side effects. Some of them are pretty easy to spot; others are more difficult.

This chapter will not cover the benefits of using functional programming. If you are interested in the benefits, I suggest you read the appendix which tackles the subject in depth. However, we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required