streaming-website/lib/PhpTemplate.php
Jannik Beyerstedt 1cd3e2b60b PHP 8: Fix major compatibility issues
PHP8 deprecated, that class member variables can be created outside the class
definition or constructor, which prevented the code to run at all. Additionally
the error handling has changed, which has lead to multiple other errors during
the runtime.
Finally, strftime was deprecated in PHP 8.1.
2023-10-27 20:18:21 +02:00

43 lines
613 B
PHP

<?php
// Version 1.2
if(!function_exists('h'))
{
function h($s)
{
return htmlspecialchars($s);
}
}
class PhpTemplate
{
private $data = array();
public $file;
public function __construct($file)
{
$this->file = $file;
$this->data["naked"] = false;
}
public function set($___data = array())
{
$this->data = array_merge($this->data, $___data);
}
public function render($___data = array())
{
extract(array_merge($this->data, $___data));
unset($___data);
ob_start();
require($this->file);
return ob_get_clean();
}
public function __tostring()
{
return $this->render();
}
}