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


PHP resource::eof方法代碼示例

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


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

示例1: date

 /**
  * Send the given string of data to the server.
  *
  * @param   string  $data    The string of data to send.
  *
  * @return  mixed   True on success or a PEAR_Error object on failure.
  *
  * @access  private
  * @since  1.0
  */
 function _send($data)
 {
     if ($this->_socket->eof()) {
         return new PEAR_Error('Failed to write to socket: (connection lost!) ');
     }
     if (PEAR::isError($error = $this->_socket->write($data))) {
         return new PEAR_Error('Failed to write to socket: ' . $error->getMessage());
     }
     if ($this->_debug) {
         // C: means this data was sent by  the client (this class)
         echo "C: " . date("H:i:s") . " " . htmlspecialchars($data) . "\n";
         $this->dbgDialog .= "C: {$data}";
     }
     return true;
 }
開發者ID:drognisep,項目名稱:Simple-Groupware,代碼行數:25,代碼來源:IMAPProtocol.php

示例2:

 /**
  * Send the given string of data to the server.
  *
  * @param string $data The string of data to send.
  *
  * @return mixed True on success or a PEAR_Error object on failure.
  *
  * @access private
  * @since 1.0
  */
 function _send($data)
 {
     if ($this->_socket->eof()) {
         return new PEAR_Error('Failed to write to socket: (connection lost!)');
     }
     if (PEAR::isError($error = $this->_socket->write($data))) {
         return new PEAR_Error('Failed to write to socket: ' . $error->getMessage());
     }
     if ($this->_debug) {
         // C: means this data was sent by  the client (this class)
         echo 'C: ' . $data;
         $this->dbgDialog .= 'C: ' . $data;
     }
     return true;
 }
開發者ID:abhinay100,項目名稱:fengoffice_app,代碼行數:25,代碼來源:IMAPProtocol.php

示例3: remove

 /**
  * remove host from hosts file.
  *
  * @param string The $host to be removed to the hosts file
  *
  * @throws RuntimeException if host does not exists or cant write to file
  *
  * @return bool
  **/
 public function remove($host)
 {
     $this->validHost($host);
     if (!$this->check($host)) {
         throw new \RuntimeException('Host does not exists in the file');
     }
     $this->backup();
     $tmpFilePath = $this->filepath . '.tmp';
     $tmpFile = new \SplFileObject($tmpFilePath, 'w+');
     $this->file->rewind();
     while (!$this->file->eof()) {
         $pattern = '/\\b' . $host . '\\b/i';
         if (!preg_match($pattern, $this->file->current())) {
             $tmpFile->fwrite($this->file->current());
         }
         $this->file->next();
     }
     copy($tmpFilePath, $this->filepath);
     unlink($tmpFilePath);
     return true;
 }
開發者ID:jjpmann,項目名稱:php-hosts-manager,代碼行數:30,代碼來源:HostsFile.php

示例4: array

 /**
  * Get data until a line with only a '.' in it is read and return data.
  *
  * @return mixed (array) text response on success or (object) pear_error on failure
  * @access private
  */
 function _getTextResponse()
 {
     $data = array();
     $line = '';
     // Continue until connection is lost
     while (!$this->_socket->eof()) {
         // Retrieve and append up to 1024 characters from the server.
         $line .= $this->_socket->gets(1024);
         if (PEAR::isError($line)) {
             return PEAR::throwError('Failed to read from socket!', null, $line->getMessage());
         }
         // Continue if the line is not terminated by CRLF
         if (substr($line, -2) != "\r\n" || strlen($line) < 2) {
             continue;
         }
         // Validate recieved line
         if (false) {
             // Lines should/may not be longer than 998+2 chars (RFC2822 2.3)
             if (strlen($line) > 1000) {
                 return PEAR::throwError('Invalid line recieved!', null);
             }
         }
         // Remove CRLF from the end of the line
         $line = substr($line, 0, -2);
         // Check if the line terminates the textresponse
         if ($line == '.') {
             // return all previous lines
             return $data;
             break;
         }
         // If 1st char is '.' it's doubled (NNTP/RFC977 2.4.1)
         if (substr($line, 0, 2) == '..') {
             $line = substr($line, 1);
         }
         // Add the line to the array of lines
         $data[] = $line;
         // Reset/empty $line
         $line = '';
     }
     return PEAR::throwError('Data stream not terminated with period', null);
 }
開發者ID:Esleelkartea,項目名稱:kz-adeada-talleres-electricos-,代碼行數:47,代碼來源:Client.php

示例5: setCryptoKey

 /**
  * Setup default cryptographic key for encrypt/decrypt operations
  *
  * @param string|resource|SplFileObject $cryptoKey cryptographic key or file
  *
  * @return $this
  */
 public function setCryptoKey($cryptoKey)
 {
     if ($cryptoKey instanceof SplFileObject) {
         $key = [];
         while (!$cryptoKey->eof()) {
             $key[] = $cryptoKey->fgets();
         }
         $this->cryptoKey = implode('', $key);
     } else {
         if (is_resource($cryptoKey) && get_resource_type($cryptoKey) == 'stream') {
             $this->cryptoKeyResource = $cryptoKey;
             $key = [];
             while (!feof($cryptoKey)) {
                 $key[] = fgets($cryptoKey);
             }
             $this->cryptoKey = implode('', $key);
         } else {
             if ((is_string($cryptoKey) || is_numeric($cryptoKey)) && @file_exists($cryptoKey)) {
                 $this->cryptoKey = file_get_contents($cryptoKey);
             } else {
                 $this->cryptoKey = $cryptoKey;
             }
         }
     }
     if (is_array($cryptoKey)) {
         $this->cryptoKey = implode('', $cryptoKey);
         $this->key = isset($cryptoKey['key']) ? $cryptoKey['key'] : array_shift($cryptoKey);
         $this->iv = isset($cryptoKey['iv']) ? $cryptoKey['iv'] : array_shift($cryptoKey);
     } else {
         list($this->key, $this->iv) = $this->splitKeyIv();
     }
     return $this;
 }
開發者ID:sacredwebsite,項目名稱:scalr,代碼行數:40,代碼來源:CryptoTool.php


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