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


PHP SplStack::shift方法代码示例

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


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

示例1: shift

 /**
  * @return ResourceInterface
  */
 public function shift()
 {
     return $this->transform(parent::shift());
 }
开发者ID:treehouselabs,项目名称:feeder,代码行数:7,代码来源:ResourceCollection.php

示例2: onRead

 /**
  * Called when new data received
  */
 public function onRead()
 {
     if ($this->state === self::STATE_BODY) {
         goto body;
     }
     if ($this->reqType === null) {
         if ($this->requests->isEmpty()) {
             $this->finish();
             return;
         }
         $this->reqType = $this->requests->shift();
     }
     while (($line = $this->readLine()) !== null) {
         if ($line !== '') {
             if ($this->rawHeaders !== null) {
                 $this->rawHeaders[] = $line;
             }
         } else {
             if (isset($this->headers['HTTP_CONTENT_LENGTH'])) {
                 $this->contentLength = (int) $this->headers['HTTP_CONTENT_LENGTH'];
             } else {
                 $this->contentLength = -1;
             }
             if (isset($this->headers['HTTP_TRANSFER_ENCODING'])) {
                 $e = explode(', ', strtolower($this->headers['HTTP_TRANSFER_ENCODING']));
                 $this->chunked = in_array('chunked', $e, true);
             } else {
                 $this->chunked = false;
             }
             if (isset($this->headers['HTTP_CONNECTION'])) {
                 $e = explode(', ', strtolower($this->headers['HTTP_CONNECTION']));
                 $this->keepalive = in_array('keep-alive', $e, true);
             }
             if (isset($this->headers['HTTP_CONTENT_TYPE'])) {
                 parse_str('type=' . strtr($this->headers['HTTP_CONTENT_TYPE'], [';' => '&', ' ' => '']), $p);
                 $this->contentType = $p['type'];
                 if (isset($p['charset'])) {
                     $this->charset = strtolower($p['charset']);
                 }
             }
             if ($this->contentLength === -1 && !$this->chunked && !$this->keepalive) {
                 $this->eofTerminated = true;
             }
             if ($this->reqType === 'HEAD') {
                 $this->requestFinished();
             } else {
                 $this->state = self::STATE_BODY;
             }
             break;
         }
         if ($this->state === self::STATE_ROOT) {
             $this->headers['STATUS'] = $line;
             $e = explode(' ', $this->headers['STATUS']);
             $this->responseCode = isset($e[1]) ? (int) $e[1] : 0;
             $this->state = self::STATE_HEADERS;
         } elseif ($this->state === self::STATE_HEADERS) {
             $e = explode(': ', $line);
             if (isset($e[1])) {
                 $k = 'HTTP_' . strtoupper(strtr($e[0], Generic::$htr));
                 if ($k === 'HTTP_SET_COOKIE') {
                     parse_str(strtr($e[1], [';' => '&', ' ' => '']), $p);
                     if (sizeof($p)) {
                         $this->cookie[$k = key($p)] =& $p;
                         $p['value'] = $p[$k];
                         unset($p[$k], $p);
                     }
                 }
                 if (isset($this->headers[$k])) {
                     if (is_array($this->headers[$k])) {
                         $this->headers[$k][] = $e[1];
                     } else {
                         $this->headers[$k] = [$this->headers[$k], $e[1]];
                     }
                 } else {
                     $this->headers[$k] = $e[1];
                 }
             }
         }
     }
     if ($this->state !== self::STATE_BODY) {
         return;
         // not enough data yet
     }
     body:
     if ($this->eofTerminated) {
         $body = $this->readUnlimited();
         if ($this->chunkcb) {
             $func = $this->chunkcb;
             $func($body);
         }
         $this->body .= $body;
         return;
     }
     if ($this->chunked) {
         chunk:
         if ($this->curChunkSize === null) {
             // outside of chunk
//.........这里部分代码省略.........
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:101,代码来源:Connection.php

示例3: count

<?php

$stack = new SplStack();
// errors
try {
    $stack->pop();
} catch (RuntimeException $e) {
    echo "Exception: " . $e->getMessage() . "\n";
}
try {
    $stack->shift();
} catch (RuntimeException $e) {
    echo "Exception: " . $e->getMessage() . "\n";
}
// data consistency
$a = 2;
$stack->push($a);
echo $stack->pop() . "\n";
// peakable
$stack->push(1);
$stack->push(2);
echo $stack->top() . "\n";
// iterable
foreach ($stack as $elem) {
    echo "[{$elem}]\n";
}
// countable
$stack->push(NULL);
$stack->push(NULL);
echo count($stack) . "\n";
echo $stack->count() . "\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:dllist_004.php

示例4: printOutput

function printOutput(SplStack $outputStack)
{
    while ($outputStack->count() !== 0) {
        echo $outputStack->shift();
    }
    echo PHP_EOL;
}
开发者ID:shikharsubedi,项目名称:spoj,代码行数:7,代码来源:reversePolish.php


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