How can object-oriented programming (OOP) in PHP, specifically using the TemplateEngine Smarty, affect the retrieval and display of data like version numbers?

When using object-oriented programming in PHP with the TemplateEngine Smarty, version numbers can be easily retrieved and displayed by creating a class specifically for handling version information. This class can encapsulate the logic for retrieving the version number and passing it to the Smarty template for display. By separating the version handling into its own class, the code becomes more organized and maintainable.

// VersionInfo.php
class VersionInfo {
    public function getVersionNumber() {
        // Logic to retrieve version number, for example from a configuration file
        return "1.0.0";
    }
}

// index.php
require_once('libs/Smarty.class.php');
require_once('VersionInfo.php');

$smarty = new Smarty();
$versionInfo = new VersionInfo();

$smarty->assign('version', $versionInfo->getVersionNumber());
$smarty->display('index.tpl');