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


PHP Stack::Push方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     // Enforce time limit, ignore aborts
     set_time_limit(2);
     ignore_user_abort();
     // Load constants
     require_once 'system/core/constants.php';
     // Set error reporting (debuging mode)
     if (debug) {
         error_reporting(E_ALL ^ E_DEPRECATED);
     }
     // Load security
     require_once 'system/core/security.php';
     // Load dependencies
     require_once 'system/core/dependencies.php';
     // Session handling
     date_default_timezone_set(local_timezone);
     session_start();
     // Initialize the stack (stack routing)
     Stack::Push((isset($_REQUEST[route_key]) and trim($_REQUEST[route_key]) != '') ? $_REQUEST[route_key] : route_home);
     // Initialize buffering
     ob_start();
     // Cycle the processes stack, run all the processors sucessively until the stack is empty.
     while (Stack::Ahead() > 0) {
         // Pre-init / re-init 'found' flag (in case the stack had multiple items)
         $found = false;
         // Catch anything that might happen
         try {
             foreach (route_repos as $rep => $types) {
                 if (!is_array($types)) {
                     $types = array($types);
                 }
                 foreach ($types as $t) {
                     $p = $rep . Stack::Top() . $t;
                     if (is_file($p)) {
                         $found = true;
                         // Update the output sequencer
                         Output::Path(Stack::Path());
                         if (!(include $p)) {
                             throw new SystemException(sprintf(err_include500, Stack::Top()));
                         }
                         break 2;
                     }
                 }
             }
             if (!$found) {
                 throw new SystemException(sprintf(err_include404, Stack::Top()));
             }
             // Processor completed; pop the stack
             Stack::Pop();
         } catch (Exception $e) {
             throw new SystemException($e);
         }
     }
     $this->buffer = ob_get_contents();
     ob_end_clean();
     // Pass the buffer to the output handler for final render
     Output::Flush($this->buffer);
     exit(1);
 }
开发者ID:xcelaio,项目名称:xcela,代码行数:60,代码来源:core.php

示例2: Push

 */
class Stack
{
    //LIFO stack example
    protected $stack = array();
    public function Push($item)
    {
        $this->stack[] = $item;
    }
    public function Pop()
    {
        return array_pop($this->stack);
    }
}
$stack = new Stack();
$stack->Push("first element");
$stack->Push("second element");
$stack->Push("third element");
var_dump($stack);
$last = $stack->Pop();
printf("Last stack element: %s\n", $last);
var_dump($stack);
//no element in stack
for ($i = 0; $i < 3; $i++) {
    $last = $stack->Pop();
    printf("Last stack element: %s\n", $last);
}
//new extended implementation
class NewStack extends Stack
{
    public function isEmpty()
开发者ID:gergund,项目名称:PHP-OOP-Lessons,代码行数:31,代码来源:lesson2-1.php


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