Пример #1
0
 private function ResolveInclude()
 {
     $matches = array();
     if (mb_ereg_match_all($this->global_settings['include'], $this->tpl, $matches, 'ipr', 1)) {
         foreach ($matches as $match) {
             $pump = new pump();
             $tpl = file_get_contents($this->tpl_path . $match[1] . ".pump");
             $fragment = $pump->ParseTemplate($tpl, $this->data);
             $this->tpl = str_replace($match[0], $fragment, $this->tpl);
         }
     }
 }
Пример #2
0
 function infuse_gas(pump $pump)
 {
     echo "pinto: ";
     $pump->get_gas();
 }
Пример #3
0
 public function __construct()
 {
     self::$global_tags = ['operationOpen' => '{@', 'operationClose' => '}', 'interpolateOpen' => '\\${', 'interpolateClose' => '}', 'noneencodeOpen' => '\\$\\${', 'noneencodeClose' => '}', 'commentOpen' => '\\{#', 'commentClose' => '\\}'];
     self::$global_options = ['cache' => true, 'strip' => true, 'errorhandling' => true, 'detection' => true];
     $this->tagInit();
 }
Пример #4
0
    }
}
class soccerball extends inflataBall
{
    public function __construct()
    {
        $this->diameter = "22cm";
        $this->targetPSI = 12;
    }
}
class basketball extends inflataBall
{
    public function __construct()
    {
        $this->diameter = "24cm";
        $this->targetPSI = 9;
    }
}
class pump
{
    public static function inflate(inflataBall $ball)
    {
        $ball->inflate(5);
    }
}
$b = new basketball();
pump::inflate($b);
pump::inflate($b);
pump::inflate($b);
pump::inflate($b);
Пример #5
0
<?php

/**
 * Created by PhpStorm.
 * User: zjian
 * Date: 2015/12/24
 * Time: 9:27
 */
require_once "../lib/pump.php";
$tpl = file_get_contents('demo.pump');
$data = array('list' => array(array('name' => '讨论组', 'age' => 18), array('name' => '私は', 'age' => 28)), 'maps' => array(array('name' => 'li', 'age' => 38), array('name' => 'الصين', 'age' => 48)), 'page' => 3);
$pump = new pump(dirname(__FILE__) . DS);
//$pump->setTags('operationOpen','<%');
echo $pump->ParseTemplate($tpl, $data);