PHP code example of carry0987 / template-engine

1. Go to this page and download the library: Download carry0987/template-engine 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/ */

    

carry0987 / template-engine example snippets


// Database configuration
$config = array(
    'host' => 'localhost',
    'port' => 3306,
    'database' => 'template',
    'username' => 'root',
    'password' => ''
);
$database = new DBController($config);

// Redis configuration
$redisConfig = array(
    'host' => 'redis',
    'port' => 6379,
    'password' => '',
    'database' => 1
);
$redis = new RedisController($redisConfig);

<span> echo $value; 


$test = <<<EOF

<span>html content</span>

EOF;

 if(expr1) { 

 foreach($array as $value) {

 foreach($array as $key => $value) {

 eval $value = 1+2;

<span>html content</span>
<script>
const value = 1+2;
document.querySelector('span').innerHTML = `Value: ${value}`;
</script>
html
<img src="{static img/logo.png}" alt="logo">
html
<img src="static/img/logo.png" alt="logo">
html
<span>{$value}</span>
html
<!--{if expr1}-->
    statement1
<!--{elseif expr2}-->
    statement2
<!--{else}-->
    statement3
<!--{/if}-->
html
<!--{loop $array $value}-->
    <span>username</span>
<!--{/loop}-->
html
<!--{loop $array $key $value}-->
    <span>{$key} = {$value}</span>
<!--{/loop}-->
html
<!--{eval $value = 1+2}-->
<span>{$value}</span>