Example 1 - Say Hello!
This is the first example with a simple key->value array.
Here we use a single content template with the identifier [content].
To make things easier to understand, we put the examples into simple include files and display the result in the yellow box.
Let me say that the concept of PbClasses ist to work with classes and not with inlude files and simple functions. But it's exactly right for this purpose.
The code for PHP and the templates is shown below.
Later you can take a look at the files
classes/MyProject/ShowExamplePage.php
examples/templates/outer.tpl
to see how a whole example page is put together. of course using PbTpl.
Hello world
I would be very happy if my examples were clear.
PHP-Code
<?php
use PbClasses\PbTpl;
try {
$c = new PbTpl('./templates/content_hello.tpl');
} catch (\Exception $exc) {
echo $exc->getMessage();
exit;
}
$seRe = [ //search-replace array
'head' => 'Hello world',
'paragraph' => 'I would be very happy if my examples were clear.',
];
return $c->fillTpl('content',$seRe);
Template-Code
[content]
<h1>{HEAD}</h1>
<p>{PARAGRAPH}</p>