What are the differences between using functions and classes in PHP for code organization and reusability?

Using functions in PHP allows for modular code organization by encapsulating specific tasks or operations into reusable blocks of code. Functions can be easily called multiple times throughout a script, promoting code reusability. On the other hand, classes in PHP offer a more object-oriented approach to code organization, allowing for the grouping of related functions and data into a single unit. Classes promote code reusability by enabling the creation of multiple instances of the same structure.

// Example using functions for code organization and reusability
function calculateArea($radius) {
    return pi() * $radius * $radius;
}

$circle1Area = calculateArea(5);
$circle2Area = calculateArea(10);

// Example using classes for code organization and reusability
class Circle {
    public $radius;

    public function __construct($radius) {
        $this->radius = $radius;
    }

    public function calculateArea() {
        return pi() * $this->radius * $this->radius;
    }
}

$circle1 = new Circle(5);
$circle2 = new Circle(10);

$circle1Area = $circle1->calculateArea();
$circle2Area = $circle2->calculateArea();