PHP Functional Programming Pure functions

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

A pure function is a function that, given the same input, will always return the same output and are side-effect free.

// This is a pure function
function add($a, $b) {
    return $a + $b;
}

Some side-effects are changing the filesystem, interacting with databases, printing to the screen.

// This is an impure function
function add($a, $b) {
    echo "Adding...";
    return $a + $b;
}


Got any PHP Question?