當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Context::request方法代碼示例

本文整理匯總了PHP中Context::request方法的典型用法代碼示例。如果您正苦於以下問題:PHP Context::request方法的具體用法?PHP Context::request怎麽用?PHP Context::request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Context的用法示例。


在下文中一共展示了Context::request方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: before

 public function before()
 {
     parent::before();
     $this->_ctx =& Context::instance();
     $this->_ctx->request($this->request)->response($this->response);
     View::bind_global('ctx', $this->_ctx);
 }
開發者ID:ZerGabriel,項目名稱:cms-1,代碼行數:7,代碼來源:front.php

示例2: main

 /**
  * Main program
  */
 public static function main()
 {
     $context = new Context();
     $context->request();
     $context->request();
     $context->request();
     $context = null;
 }
開發者ID:luisOO,項目名稱:design-patterns,代碼行數:11,代碼來源:client.php

示例3: __construct

            $c->state = new NormalState();
            echo "<Normal state>\n";
        }
        $c->counter -= 5;
        return $c->counter;
    }
}
class Context
{
    const LIMIT = 10;
    public $state;
    public $counter;
    public function __construct()
    {
        $this->counter = self::LIMIT;
    }
    public function request(int $i) : int
    {
        if ($i == 2) {
            return $this->state->moveUp($this);
        } else {
            return $this->state->moveDown($this);
        }
    }
}
$context = new Context();
$context->state = new NormalState();
for ($i = 0; $i < 500; ++$i) {
    $r = mt_rand(1, 3);
    echo $context->request($r), "\n";
}
開發者ID:edin,項目名稱:php-design-patterns,代碼行數:31,代碼來源:State.php

示例4: handle

    }
}
class StateB implements State
{
    public function handle($context)
    {
        $context->setState(new StateC());
    }
    public function display()
    {
        echo "State B\n";
    }
}
class StateC implements State
{
    public function handle($context)
    {
        $context->setState(new StateA());
    }
    public function display()
    {
        echo "State C\n";
    }
}
//實例化
$objContext = new Context(new StateB());
$objContext->request();
$objContext->request();
$objContext->request();
$objContext->request();
$objContext->request();
開發者ID:rick00young,項目名稱:StudyNote,代碼行數:31,代碼來源:State.php

示例5: handle

    }
    public function handle(Context $context)
    {
        echo 'concrete_b' . "<br>";
        $context->setState(ConcreteStateA::getInstance());
    }
}
class Context
{
    // 環境角色
    private $_state;
    public function __construct()
    {
        // 默認為stateA
        $this->_state = ConcreteStateA::getInstance();
    }
    public function setState(State $state)
    {
        $this->_state = $state;
    }
    public function request()
    {
        $this->_state->handle($this);
    }
}
// client
$context = new Context();
$context->request();
$context->request();
$context->request();
$context->request();
開發者ID:yunkaiyueming,項目名稱:php_design_patterns,代碼行數:31,代碼來源:state.php


注:本文中的Context::request方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。