How can a PHP developer effectively handle data retrieval from multiple PHP files?

When retrieving data from multiple PHP files, a PHP developer can effectively handle this by using include or require statements to pull in the necessary files containing the data. By organizing the data retrieval logic into separate files and including them where needed, the codebase remains modular and easier to maintain.

// File: data1.php
$data1 = "Data from file 1";

// File: data2.php
$data2 = "Data from file 2";

// File: main.php
require 'data1.php';
require 'data2.php';

echo $data1 . "<br>";
echo $data2;