PHP code example of naingaunglwin-dev / view

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

    

naingaunglwin-dev / view example snippets


{
  ""naingaunglwin-dev/view": "^1.0"
  }
}



AL\View\View;

$view = new View(__DIR__ . '/views');

// You can pass view file without extension if it is php file
$view->render('index', ['status' => 'success']);

// You can also render other file,
// You can retrieve the view without rendering,
$indexView = $view->render('index.html', [], true);

// You can also render multi views
$view->render(['index.html, test']);

 //one.php

echo 'this is one.php';
$this->displaySection('content');

 //two.php
$this->extends('one'); // view file name that need to extend

$this->section('content'); // Section start with `content` name

echo '<br>This is section content from two.php';

$this->endSection('content'); // End the section `content`



AL\View\View;

$view = new View(__DIR__ . '/views');

$view->render('two');