1. Go to this page and download the library: Download aesonus/message-templates library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
abstract class ConstTemplateSource implements TemplateSourceInterface
{
public function getTemplate(): string
{
return TEMPLATES[$this->key];
}
}
class Key1 extends ConstTemplateSource {
protected $key = 'key1';
}
class Key2 extends ConstTemplateSource {
protected $key = 'key2';
}
// Create the render object
$template = new RenderVsprintfTemplate();
// Set the template source for the render object
$template->setSource(new Key1);
//Output the template with data
echo $template->render(['purple']);
//Outputs: template string, purple
// Set another template source for the render object
$template->setSource(new Key2);
//Output the template with data
echo $template->render(['red']);
//Outputs: template string two, red
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.