How can the issue of resetting the value in PHP when loading new data be addressed in a lazy loading scenario?

In a lazy loading scenario in PHP, the issue of resetting the value when loading new data can be addressed by checking if the value already exists before setting it again. This can be done by using an if statement to only set the value if it is not already set.

// Check if the value is already set before setting it again
if (!isset($value)) {
    $value = fetchData(); // Load new data
}