<?php $customTemplate = " <div> <<This>> <<that>> </div> "; $MyClass = new class{ function get($tag) { if ($tag == 'This') return '<h1>Something</h1>'; if ($tag == 'that') return '<p>For example</p>'; return '**not found**'; } }; function process_template($template, $MyClass, $begin = '<<', $end = '>>') { return preg_replace_callback("/$begin(\w+)$end/", function($var) use ($MyClass) { return $MyClass->get($var[1]); }, $template); } $processed = process_template($customTemplate, $MyClass); var_dump($processed);
You have javascript disabled. You will not be able to edit any code.