arisuchan    [ tech / cult / art ]   [ λ / Δ ]   [ psy ]   [ ru ]   [ random ]   [ meta ]   [ all ]    info / stickers     temporarily disabledtemporarily disabled

/b/ - experimental

stand back. this is a test. please test experimental features here.
Name
Email
Subject
Comment

formatting options

File
Password (For file deletion.)

Help me fix this shit. https://legacy.arisuchan.jp/q/res/2703.html#2703

Kalyx ######


File: 1504569076295.jpg (17.71 KB, 256x256, mQRDHcpE.jpg)

 No.160

<?php

/*
 * SCORE ( 18 pts )
 *
 * file : 1
 * statements : 11
 * variables : 6 (arrays and class instance are counted as a variable)
 */

/*
 * We use the PHP's autoload function to load dynamicaly classes.
 */
require_once("autoload.php");

/*
 * We use a template engine because as you know it is far better
 * to use MVC :-)
 */
require_once("lib/twig/lib/Twig/Autoloader.php");
Twig_Autoloader::register();

/*
 * We create a new Twig Environment with debug and templates cache.
 */
$twig = new Twig_Environment(

    new Twig_Loader_Filesystem(

        "design/templates" /* The place where to look for templates */

    ),
    array(
        'debug' => true,
        'cache' => 'var/cache/templates'
    )

);
/* 
 * We add the debug extension because we should be able to detect what is wrong if needed
 */
$twig->addExtension(new Twig_Extension_Debug());

/*
 * We create a new page to be displayed in the body.
 */
$page = new Page();

/*
 * We add our famous title : Hello World !!!
 */
$page->add( 'Title', array( 'level' => 1, 'text' => 'Hello World' ) );

/*
 * We are now ready to render the content and display it.
 */
$final_result = $twig->render(

    'pages/hello_world.twig',
    array(

        'Page' => $page->toXML()

    )

);

/*
 * Everything is OK, we can print the final_result to the page.
 */
echo $final_result;

?>


[Return] [Go to top] [ Catalog ] [Post a Reply]
Delete Post [ ]