当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::map方法代码示例

本文整理汇总了PHP中Application::map方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::map方法的具体用法?PHP Application::map怎么用?PHP Application::map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Application的用法示例。


在下文中一共展示了Application::map方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

use Koi\CLI;
// Create our application
class Application extends Koi\Application
{
    public function __construct()
    {
        CLI::$banner = 'Usage: php cli.php [command] [switches]';
        CLI::set_opt(NULL, 'help', 'Show this help message');
        CLI::set_opt('name', 'name', 'Specify your name', TRUE);
    }
    public function index()
    {
        CLI::show_help();
    }
    public function name()
    {
        if (CLI::get_opt('help') === NULL) {
            CLI::show_help('name');
            exit;
        }
        $name = CLI::get_opt('name');
        if ($name === FALSE) {
            CLI::terminate('name', 'You need to specify a name');
        }
        echo "Your name is {$name}" . PHP_EOL;
    }
}
$app = new Application();
$app->map('/', 'index');
$app->map('/name', 'name');
$app->run();
开发者ID:ngonchan,项目名称:koi,代码行数:31,代码来源:cli.php

示例2: index

<?php

require_once __DIR__ . '/../lib/koi.php';
// Create our application
class Application extends Koi\Application
{
    public function index()
    {
        return "Hello, world!";
    }
    public function not_found()
    {
        return array("The requested page could not be found", 404);
    }
}
$app = new Application();
$app->map('/', 'index');
$app->map('/:404', 'not_found');
$app->run();
开发者ID:ngonchan,项目名称:koi,代码行数:19,代码来源:index.php

示例3: regex

    {
        return "alphanumeric method";
    }
    public function regex()
    {
        return "regex method";
    }
    public function not_found()
    {
        return "404 method";
    }
    public function sub_not_found()
    {
        return "sub 404 method";
    }
    public function route_args($number)
    {
        return "route with args method {$number}";
    }
}
$app = new Application();
$app->map('/', 'index');
$app->map('/:alpha', 'alphabetic');
$app->map('/hello/world', 'sub_route');
$app->map('/:numeric', 'numeric');
$app->map('/:alphanumeric', 'alphanumeric');
$app->map('/koi-([a-zA-Z0-9])+', 'regex');
$app->map('/route_args/:numeric', 'route_args:args');
// Note that in order to prevent collisions 404 routes should be added at the very end.
$app->map('/:alphanumeric/:404', 'sub_not_found');
$app->map('/:404', 'not_found');
开发者ID:ngonchan,项目名称:koi,代码行数:31,代码来源:routes.php

示例4: index

<?php

class Application extends Koi\Application
{
    public function index()
    {
        return "Hello, index!";
    }
    public function param($name, $surname)
    {
        return "hello {$name} {$surname}";
    }
}
$app = new Application();
$app->map('/', 'index');
$app->map('/param', 'param:args');
开发者ID:ngonchan,项目名称:koi,代码行数:16,代码来源:simple.php

示例5: index

<?php

class Application extends Koi\Application
{
    public function index()
    {
        return array("index method", 200, "text/html");
    }
    public function not_found()
    {
        return array("not_found method", 404, "text/html");
    }
    public function no_content()
    {
        return array("no_content method", 200);
    }
}
$app = new Application();
$app->map('/', 'index');
$app->map('/not_found', 'not_found');
$app->map('/no_content', 'no_content');
开发者ID:ngonchan,项目名称:koi,代码行数:21,代码来源:returns.php

示例6: index

require_once __DIR__ . '/../../lib/koi.php';
use Koi\Cookie;
class Application extends Koi\Application
{
    public function index()
    {
        $c = new Cookie('name', 'Yorick Peterse', NULL, '/', time() + 86400);
        $c->save();
        return $c->value;
    }
    public function name()
    {
        $c = new Cookie('name');
        return $c->value;
    }
    public function delete()
    {
        $c = new Cookie('name');
        if ($c->destroy()) {
            return "Cookie destroyed";
        } else {
            return "Failed to destroy the cookie";
        }
    }
}
$app = new Application();
$app->map('/', 'index');
$app->map('/name', 'name');
$app->map('/delete', 'delete');
$app->run();
开发者ID:ngonchan,项目名称:koi,代码行数:30,代码来源:cookie.php

示例7:

<?php

include 'lib/bootstrap.php';
Application::map('(.*)', 'Welcome');
Application::run();
开发者ID:jasonjohnson,项目名称:blast,代码行数:5,代码来源:index.php


注:本文中的Application::map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。