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;
}