PHP code example of ayesh / phptemplate

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

    

ayesh / phptemplate example snippets


$template = new Ayesh\PHPTemplate\PHPTemplate('test-template.php'); // <-- Path to the template file.
$contents = $template->render();
// $contents will contain the contents of the `test-template.php` file.

Good morning <em><?= $v['name']; 

$vars = [
  'name' => '<script>alert("xss!");</script>',
  'sitename' => 'PHPTemplate',
];
$template = new Ayesh\PHPTemplate\PHPTemplate('test-template.php');
$contents = $template->render($vars);

<a href="<?= $v[':user_website']; 

$vars = [
  'user_website' => 'javascript:alert("xss");',
];
$template = new Ayesh\PHPTemplate\PHPTemplate('test-template.php');
$contents = $template->render($vars);



<a <?= $v->attributes(['href' => 'https://ayesh.me', 'rel' => 'nofollow');