How to get PEAR Templates to work with the latest version of PHP

PEAR HTML_Template_IT with PHP 5.5.0+

If you have been using PEAR templates, you might have noticed that with the recent PHP upgrades, the templates stopped working. There are a couple reasons for this:
  • Later Versions of PHP deprecate the preg_replace() function

  • Later Versions of PHP use __construct to denote a construction instead of naming the constructor to match the class

A Solution

Copy and paste the following code into the IT.PHP file.

In your PHP files, be sure to include IT.php instead of ITX.php and replace the main call of
$tpl = new HTML_Template_ITX();
with
$tpl = new HTML_Template_IT(); Read more about using PEAR templates

Comments