PHP code example of inanepain / view

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

    

inanepain / view example snippets


// TODO: PhpRenderer example

$data = [
    'label' => ['label' => 'Inane Website'],
    'a' => ['title' => 'Inane', 'url' => 'https://inane.co.za'],
];

$sr = new StringRenderer([
    'label' => '<label>{$label}</label>',
    'a' => '<a href="{$url}">{$title}</a>',
]);

echo $sr->render('label', $data['label'], true) . PHP_EOL;
echo $sr->render('a', $data['a'], true) . PHP_EOL;

echo $sr->render('label', ['label' => 'Google'], true) . PHP_EOL;
echo $sr->render('a', ['title' => 'SA', 'url' => 'https://www.google.co.za'], true) . PHP_EOL;
echo $sr->render('a', ['title' => 'International', 'url' => 'https://www.google.com'], true) . PHP_EOL;

echo $sr->render('<h1>{$heading}</h1>', ['heading' => 'Bob'], false) . PHP_EOL;