Beispiel #1
0
echo '$classLoader->register();';
require_once __DIR__ . "/../src/SplClassLoader.php";
$classLoader = new SplClassLoader("Library", __DIR__ . "/../src");
$classLoader->register();
?>
    </pre>

<h3 id="helpers">Library\Helper</h3>

    <p>The <var>Helpers</var> of the package all defines some static methods.</p>

<h4 id="urlhelper">Library\Helper\Url</h4>
    <pre class="code" data-language="php">
<?php 
echo 'echo Library\\Helper\\Url::getRequestUrl();' . "\n";
echo '=> ' . Library\Helper\Url::getRequestUrl();
echo "\n\n";
echo 'echo $str = "test";' . "\n";
echo 'echo Library\\Helper\\Url::isUrl($str);' . "\n";
$str = "test";
echo '=> ' . var_export(Library\Helper\Url::isUrl($str), 1);
echo "\n";
echo 'echo $str2 = "http://google.fr/";' . "\n";
echo 'echo Library\\Helper\\Url::isUrl($str2);' . "\n";
$str2 = "http://google.fr/";
echo '=> ' . var_export(Library\Helper\Url::isUrl($str2), 1);
echo "\n\n";
echo 'echo $str = "test";' . "\n";
echo 'echo Library\\Helper\\Url::isEmail($str);' . "\n";
$str = "test";
echo '=> ' . var_export(Library\Helper\Url::isEmail($str), 1);
?>
    </pre>

<h4>Custom request</h4>

    <pre class="code" data-language="php">
<?php 
/*
    public static function create(
        $url = null, $flag = self::NO_REWRITE,
        $protocol = 'http', $method = 'get', array $headers = null, 
        array $arguments = null, array $data = null, 
        array $session = null, array $files = null, array $cookies = null
    ) {
*/
$url = Library\Helper\Url::getRequestUrl(false, true);
$flag = Library\HttpFundamental\Request::NO_REWRITE;
$protocol = 'http';
$method = 'get';
$headers = null;
$get = array('get_arg1' => 'value 1', 'get_arg2' => 'value 2');
$post = array('post_arg1' => 'value 1', 'post_arg2' => 'value 2');
$session = null;
$files = null;
$cookies = null;
$custom_request = Library\HttpFundamental\Request::create($url, $flag, $protocol, $method, $headers, $get, $post, $session, $files, $cookies);
echo '$url = Library\\Helper\\Url::getRequestUrl(false, true);' . "\n";
echo '$flag = Library\\HttpFundamental\\Request::NO_REWRITE;' . "\n";
echo '$protocol = "http";' . "\n";
echo '$method = "get";' . "\n";
echo '$headers = null;' . "\n";