PHP Classes

File: examples/template.php

Recommend this page to a friend!
  Classes of Everton da Rosa   XtPHP   examples/template.php   Download  
File: examples/template.php
Role: Example script
Content type: text/plain
Description: Example script
Class: XtPHP
General purpose library of utility classes
Author: By
Last change:
Date: 9 years ago
Size: 542 bytes
 

Contents

Class file image Download
<?php
//Exemplo de utilização de XtTemplate::merge()

require '../template.php';

//Os dados a serem mesclados
$arr = array(
   
'total' => 2
   
,'line' => array(
        array(
           
'codigo' => 1
           
,'nome' => 'fulano'
       
)
        ,array(
           
'codigo' => 2
           
,'nome' => 'beltrano'
       
)
    )
);

//O Template
$tpl = "<table border=1>
<tr><td>Código</td><td>Nome</td></tr>
{{line:}}<tr><td>{{codigo}}</td><td>{{nome}}</td></tr>{{:line}}
<tr><td colspan=2>Total de linhas: {{total}}</td></tr>
</table>"
;

echo
XtTemplate::merge($arr, $tpl);//O resultado final
?>