Beispiel #1
0
<?php

// This file has been placed in the public domain by Benjamin Althues
/* Init composer autoloader and import Simphplist components into namespace
** ------------------------------------------------------------------------ */
if (!defined('SIMPHPLIST_EXAMPLES_NO_LOADER') || !SIMPHPLIST_EXAMPLES_NO_LOADER) {
    @(include dirname(dirname(__DIR__)) . "/vendor/autoload.php") || die('Please run `composer install`.');
}
use Simphplist\Simphplist\Request;
use Simphplist\Simphplist\String;
/* Initialize Twig template (system)
** ------------------------------------------------------------------------ */
$twig = (new Twig_Environment(new Twig_Loader_Filesystem(dirname(dirname(__DIR__)) . '/tpl')))->loadTemplate('text-1.tpl');
/* Simphplist
** ------------------------------------------------------------------------ */
// Sanitize POST input
$text = Request::post('text');
// Count and differentiate paragraphs, lines, words and chars
$info = String::count($text) ?: array();
$keys_to_skip = array('words_list', 'chars_list', 'words_list_perc', 'chars_list_perc');
// Render template
echo $twig->render(array('section' => 'text-1', 'subtitle' => 'Text example 1', 'text' => $text, 'info' => $info, 'keys_to_skip' => $keys_to_skip));
Beispiel #2
0
<?php

function autoload($className)
{
    $className = ltrim($className, '\\');
    $fileName = '';
    $namespace = '';
    if ($lastNsPos = strrpos($className, '\\')) {
        $namespace = substr($className, 0, $lastNsPos);
        $className = substr($className, $lastNsPos + 1);
        $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
    }
    $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
    require $fileName;
}
autoload('\\Simphplist\\Simphplist\\Request');
use Simphplist\Simphplist\Request;
echo Request::get('test', 'use ?test=string');