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


PHP SplStack::next方法代碼示例

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


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

示例1: log

 /**
  * Logs with an arbitrary level.
  *
  * @param string $level
  * @param string|array $message a textual message, encoded JSON or array to encode into JSON
  * @param array $context context regarding the message, if this is included it will
  *                       added to the message as json or included in the json payload
  * @throws \InvalidArgumentException
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     $this->connectIfNotConnected();
     if (is_array($message)) {
         $message = json_encode($message);
     }
     if (!is_string($message)) {
         throw new \InvalidArgumentException('the message argument needs to be a string or an array');
     } else {
         $isJson = $this->isJSON($message);
         if ($isJson) {
             $json = json_decode($message, true);
             if ("" != $this->_hostname) {
                 $json["hostname"] = $this->_hostname;
             }
             $json["level"] = $level;
             if (count($context) > 0) {
                 $json["context"] = $context;
             }
             $message = json_encode($json);
         } else {
             $message = strtoupper($level) . " - " . $message;
             if ("" != $this->_hostname) {
                 $message = "hostname={$this->_hostname} - " . $message;
                 if (count($context) > 0) {
                     $message .= " - " . json_encode($context);
                 }
             }
         }
         $this->_writer_stack->rewind();
         while ($this->_writer_stack->valid()) {
             /** @var LogEntriesWriter $writer */
             $writer = $this->_writer_stack->current();
             $message = $writer->log($message, $isJson);
             $this->_writer_stack->next();
         }
         $this->writeToSocket($this->substituteNewline($message) . PHP_EOL);
     }
 }
開發者ID:cbschuld,項目名稱:logentries,代碼行數:49,代碼來源:LogEntries.php

示例2: valid

 /**
  * Skip null elements while validated the current one.
  *
  * @return  bool
  */
 public function valid()
 {
     while (true === parent::valid() && null === $this->current() && null === parent::next()) {
     }
     return parent::valid();
 }
開發者ID:Grummfy,項目名稱:Central,代碼行數:11,代碼來源:WeakStack.php


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