What are the potential benefits of incorporating functions into classes in PHP?

When incorporating functions into classes in PHP, it allows for better organization and encapsulation of code. This can lead to improved code readability and maintainability. Additionally, using classes allows for the use of inheritance and polymorphism, enabling code reuse and promoting a more modular design.

class Calculator {
    public function add($num1, $num2) {
        return $num1 + $num2;
    }

    public function subtract($num1, $num2) {
        return $num1 - $num2;
    }
}

$calc = new Calculator();
echo $calc->add(5, 3); // Outputs: 8
echo $calc->subtract(5, 3); // Outputs: 2