PHP code example of blesta / h2o

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

    

blesta / h2o example snippets


         $h2o = new h2o('templates/index.html');
        echo $h2o->render(array('name'=>'Peter Jackson'));
    
 
        $h2o = new H2o('template.tpl');
        $person =array(
                'name' => 'Peter Jackson', 'age' => 25
        );
        $h2o->render(compact('person'));
    

        echo image_tag("/image/logo.png", array(
            'width' => 450, 
            'height' => 250, 
            'alt'=>'company logo'
        ));
    

        $h2o = new H2o('template.tpl', array(
            [option_name] => [option_value]
        ));
    

    $loader = new H2o_File_Loader($custom_searchpath);
    $template = new H2o('index.html', array('loader'=> $loader );
    

        $loader = dict_loader(array(
            "index.html" => 'Hello {{ person }}'
        ));
        $template = new H2o('index.html', array('loader' => $loader'));
    

        $template = new H2o('homepage.tpl', array(
            'cache' => 'file',
            'cache_dir' => '/tmp'
        ));
    

        $template = new h2o('homepage.tpl', array('cache' => 'apc'));