How can the error message "Template Error: set_root: ./tpl/ is not a directory" be resolved in PHP?

The error message "Template Error: set_root: ./tpl/ is not a directory" indicates that the specified directory for templates is not valid. To resolve this issue, you need to ensure that the directory path provided for the templates is correct and that it is indeed a directory. Check the path and permissions to make sure it is accessible by the PHP script.

// Check and set the correct directory path for templates
$template_dir = './tpl/';

if (is_dir($template_dir)) {
    // Proceed with template processing
} else {
    echo "Error: Template directory is not valid.";
}