PHP Classes

File: examples/testloop2.php

Recommend this page to a friend!
  Classes of Jorge Castro  >  BladeOne  >  examples/testloop2.php  >  Download  
File: examples/testloop2.php
Role: Example script
Content type: text/plain
Description: Example script
Class: BladeOne
Standalone template engine that compiles into PHP
Author: By
Last change: Update of examples/testloop2.php
Date: 2 months ago
Size: 823 bytes
 

Contents

Class file image Download
<?php
/**
 * Copyright (c) 2016 Jorge Patricio Castro Castillo MIT License.
 */
include "../lib/BladeOne.php";
use
eftec\bladeone\BladeOne;

$views = __DIR__ . '/views';
$compiledFolder = __DIR__ . '/compiled';
$blade=new BladeOne($views,$compiledFolder,BladeOne::MODE_DEBUG);


$users=[];

$john=new stdClass();
$john->name="John";
$john->post=[];

$annah=new stdClass();
$annah->name="Annah";
$annah->post=[];

$post1=new stdClass();
$post1->subject="Hi there 1";

$post2=new stdClass();
$post2->subject="Hi there 2";

$john->posts[]=$post1;
$john->posts[]=$post2;

$annah->posts[]=$post1;
$annah->posts[]=$post2;

$users[]=$john;
$users[]=$annah;


try {
    echo
$blade->run("Test.loop2"
       
, ["users" => $users]);
} catch (
Exception $e) {
    echo
"error found ".$e->getMessage()."<br>".$e->getTraceAsString();
}


For more information send a message to info at phpclasses dot org.