本文整理汇总了PHP中resource::gets方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::gets方法的具体用法?PHP resource::gets怎么用?PHP resource::gets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource
的用法示例。
在下文中一共展示了resource::gets方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date
/**
* Receive the given string of data from the server.
*
* @return mixed a line of response on success or a PEAR_Error object on failure.
*
* @access private
* @since 1.0
*/
function _recvLn()
{
if (PEAR::isError($this->lastline = $this->_socket->gets(8192))) {
return new PEAR_Error('Failed to write to socket: ' . $this->lastline->getMessage());
}
if ($this->_debug) {
// S: means this data was sent by the IMAP Server
echo "S: " . date("H:i:s") . " " . htmlspecialchars($this->lastline) . "\n";
$this->dbgDialog .= "S: " . $this->lastline . "";
}
if ($this->lastline == '') {
return new PEAR_Error('Failed to receive from the socket: ');
}
return $this->lastline;
}
示例2:
/**
* Receive the given string of data from the server.
*
* @return mixed a line of response on success or a PEAR_Error object on failure.
*
* @access private
* @since 1.0
*/
function _recvLn()
{
if (PEAR::isError($this->lastline = $this->_socket->gets(8192))) {
return new PEAR_Error('Failed to write to socket: ' . $this->lastline->getMessage());
}
if ($this->_debug) {
// S: means this data was sent by the IMAP Server
echo 'S: ' . $this->lastline;
$this->dbgDialog .= 'S: ' . $this->lastline;
}
if ($this->lastline == '') {
return new PEAR_Error('Failed to receive from the socket: ');
}
return $this->lastline;
}
示例3: rtrim
/**
* Receives a single line from the server.
*
* @return string The server response line.
*/
function _recvLn()
{
if (PEAR::isError($lastline = $this->_sock->gets(8192))) {
return PEAR::raiseError('Failed to read from socket: ' . $lastline->getMessage());
}
$lastline = rtrim($lastline);
$this->_debug("S: {$lastline}");
if ($lastline === '') {
return PEAR::raiseError('Failed to read from socket');
}
return $lastline;
}
示例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);
}
示例5: rtrim
/**
* Receives a single line from the server.
*
* @return string The server response line.
*/
function _recvLn()
{
$lastline = $this->_sock->gets(8192);
if (is_a($lastline, 'PEAR_Error')) {
return $this->_pear->raiseError('Failed to read from socket: ' . $lastline->getMessage());
}
$lastline = rtrim($lastline);
$this->_debug("S: {$lastline}");
if ($lastline === '') {
return $this->_pear->raiseError('Failed to read from socket');
}
return $lastline;
}