• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mb_orig_strlen函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中mb_orig_strlen函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_orig_strlen函数的具体用法?PHP mb_orig_strlen怎么用?PHP mb_orig_strlen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: import

 /**
  * Import
  * @param  mixed $id ID
  * @return mixed
  */
 public static function import($id)
 {
     if ($id instanceof static) {
         return $id;
     } elseif ($id instanceof \MongoId) {
         $id = (string) $id;
     } elseif (!is_string($id)) {
         if (is_array($id) && isset($id['$id'])) {
             return static::import($id['$id']);
         }
         return false;
     } elseif (mb_orig_strlen($id) === 24) {
         if (!ctype_xdigit($id)) {
             return false;
         }
     } elseif (ctype_alnum($id)) {
         $id = gmp_strval(gmp_init(strrev($id), 62), 16);
         if (mb_orig_strlen($id) > 24) {
             return false;
         }
         if (mb_orig_strlen($id) < 24) {
             $id = str_pad($id, 24, '0', STR_PAD_LEFT);
         }
     } else {
         return false;
     }
     return new static($id);
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:33,代码来源:MongoId.php


示例2: sendPacket

 /**
  * @TODO DESCR
  * @param $p
  */
 public function sendPacket($p)
 {
     if ($p === null) {
         return;
     }
     $data = \igbinary_serialize($p);
     $this->write(pack('N', mb_orig_strlen($data)) . $data);
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:12,代码来源:WorkerConnection.php


示例3: checksum

 /**
  * Build checksum
  * @param  string $data Source
  * @return string       Checksum
  */
 protected static function checksum($data)
 {
     $bit = unpack('n*', $data);
     $sum = array_sum($bit);
     if (mb_orig_strlen($data) % 2) {
         $temp = unpack('C*', $data[mb_orig_strlen($data) - 1]);
         $sum += $temp[1];
     }
     $sum = ($sum >> 16) + ($sum & 0xffff);
     $sum += $sum >> 16;
     return pack('n*', ~$sum);
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:17,代码来源:Connection.php


示例4: __call

 /**
  * Magic __call
  * Example:
  * $gibson->set(3600, 'key', 'value');
  * $gibson->get('key', function ($conn) {...});
  * @param  string $name Command name
  * @param  array $args Arguments
  * @return void
  */
 public function __call($name, $args)
 {
     $name = strtolower($name);
     $onResponse = null;
     if (($e = end($args)) && (is_array($e) || is_object($e)) && is_callable($e)) {
         $onResponse = array_pop($args);
     }
     if (!isset($this->opCodes[$name])) {
         throw new UndefinedMethodCalled();
     }
     $data = implode(" ", $args);
     $this->requestByServer(null, pack('LS', mb_orig_strlen($data) + 2, $this->opCodes[$name]) . $data, $onResponse);
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:22,代码来源:Pool.php


示例5: compareStrings

function compareStrings($expected, $actual)
{
    if (function_exists('mb_orig_strlen')) {
        $lenExpected = mb_orig_strlen($expected);
        $lenActual = mb_orig_strlen($actual);
    } else {
        $lenExpected = strlen($expected);
        $lenActual = strlen($actual);
    }
    $status = $lenExpected ^ $lenActual;
    $len = min($lenExpected, $lenActual);
    for ($i = 0; $i < $len; $i++) {
        $status |= ord($expected[$i]) ^ ord($actual[$i]);
    }
    return $status === 0;
}
开发者ID:Okhremchuk,项目名称:Ingenum,代码行数:16,代码来源:class.serv.php


示例6: extract

 /**
  * Extract key and value pair from line.
  * @param  string $line
  * @return array
  */
 public static function extract($line)
 {
     $e = explode(': ', $line, 2);
     $header = strtolower(trim($e[0]));
     $value = isset($e[1]) ? trim($e[1]) : null;
     $safe = false;
     foreach (self::$safeCaseValues as $item) {
         if (strncasecmp($header, $item, mb_orig_strlen($item)) === 0) {
             $safe = true;
             break;
         }
         if (strncasecmp($value, $item, mb_orig_strlen($item)) === 0) {
             $safe = true;
             break;
         }
     }
     if (!$safe) {
         $value = strtolower($value);
     }
     return [$header, $value];
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:26,代码来源:Pool.php


示例7: compareStrings

 /**
  * A timing safe comparison method.
  *
  * C function memcmp() internally used by PHP, exits as soon as a difference
  * is found in the two buffers. That makes possible of leaking
  * timing information useful to an attacker attempting to iteratively guess
  * the unknown string (e.g. password).
  *
  * @param string $expected
  * @param string $actual
  * @throws \Freetrix\Main\ArgumentTypeException
  * @return bool
  */
 protected function compareStrings($expected, $actual)
 {
     if (!is_string($expected)) {
         throw new ArgumentTypeException('expected', 'string');
     }
     if (!is_string($actual)) {
         throw new ArgumentTypeException('actual', 'string');
     }
     if (function_exists('mb_orig_strlen')) {
         $lenExpected = mb_orig_strlen($expected);
         $lenActual = mb_orig_strlen($actual);
     } else {
         $lenExpected = strlen($expected);
         $lenActual = strlen($actual);
     }
     $status = $lenExpected ^ $lenActual;
     $len = min($lenExpected, $lenActual);
     for ($i = 0; $i < $len; $i++) {
         $status |= ord($expected[$i]) ^ ord($actual[$i]);
     }
     return $status === 0;
 }
开发者ID:ASDAFF,项目名称:open_bx,代码行数:35,代码来源:hmacalgorithm.php


示例8: init

    /**
     * Constructor
     * @return void
     */
    public function init()
    {
        parent::init();
        if (isset($this->attrs->version)) {
            $this->version = $this->attrs->version;
        }
        $this->header('Cache-Control: max-age=31536000, public, pre-check=0, post-check=0');
        $this->header('Expires: ' . date('r', strtotime('+1 year')));
        $html = '<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<script>
		document.domain = document.domain;
		_sockjs_onload = function(){SockJS.bootstrap_iframe();};
	</script>
	<script src="https://cdn.jsdelivr.net/sockjs/' . htmlentities($this->version, ENT_QUOTES, 'UTF-8') . '/sockjs.min.js"></script>
</head>
<body>
	<h2>Don\'t panic!</h2>
	<p>This is a SockJS hidden iframe. It\'s used for cross domain magic.</p>
</body>
</html>';
        $etag = 'W/"' . sha1($html) . '"';
        $this->header('ETag: ' . $etag);
        if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
            if ($_SERVER['HTTP_IF_NONE_MATCH'] === $etag) {
                $this->status(304);
                $this->removeHeader('Content-Type');
                $this->finish();
                return;
            }
        }
        $this->header('Content-Length: ' . mb_orig_strlen($html));
        echo $html;
        $this->finish();
    }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:42,代码来源:Iframe.php


示例9: strlen

 function strlen($s)
 {
     if (function_exists('mb_orig_strlen')) {
         return mb_orig_strlen($s);
     }
     return strlen($s);
 }
开发者ID:Satariall,项目名称:izurit,代码行数:7,代码来源:backup.php


示例10: drawTable

 /**
  * Draw a table
  * @param  array Array of table's rows
  * @return void
  */
 public function drawTable($rows)
 {
     $pad = [];
     foreach ($rows as $row) {
         foreach ($row as $k => $v) {
             if (substr($k, 0, 1) === '_') {
                 continue;
             }
             if (!isset($pad[$k]) || strlen($v) > $pad[$k]) {
                 $pad[$k] = mb_orig_strlen($v);
             }
         }
     }
     foreach ($rows as $row) {
         if (isset($row['_color'])) {
             $this->setStyle($row['_color']);
         }
         if (isset($row['_bold'])) {
             $this->setStyle('1');
         }
         if (isset($row['_'])) {
             echo $row['_'];
         } else {
             $i = 0;
             foreach ($row as $k => $v) {
                 if (substr($k, 0, 1) === '_') {
                     continue;
                 }
                 if ($i > 0) {
                     echo "\t";
                 }
                 echo str_pad($v, $pad[$k]);
                 ++$i;
             }
         }
         $this->resetStyle();
         echo "\n";
     }
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:44,代码来源:Terminal.php


示例11: createXMLStream

 /**
  * @TODO DESCR
  */
 public function createXMLStream()
 {
     $this->xml = new XMLStream();
     $this->xml->setDefaultNS('jabber:client');
     $this->xml->addXPathHandler('{http://etherx.jabber.org/streams}features', function ($xml) {
         /** @var XMLStream $xml */
         if ($xml->hasSub('starttls') and $this->use_encryption) {
             $this->sendXML("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required /></starttls>");
         } elseif ($xml->hasSub('bind') and $this->authorized) {
             $id = $this->getId();
             $this->iqSet('<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>' . $this->path . '</resource></bind>', function ($xml) {
                 if ($xml->attrs['type'] === 'result') {
                     $this->fulljid = $xml->sub('bind')->sub('jid')->data;
                     $jidarray = explode('/', $this->fulljid);
                     $this->jid = $jidarray[0];
                 }
                 $this->iqSet('<session xmlns="urn:ietf:params:xml:ns:xmpp-session" />', function ($xml) {
                     $this->roster = new XMPPRoster($this);
                     if ($this->onConnected) {
                         $this->connected = true;
                         $this->onConnected->executeAll($this);
                         $this->onConnected = null;
                     }
                     $this->event('connected');
                 });
             });
         } else {
             if (mb_orig_strlen($this->password)) {
                 $this->sendXML("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("" . $this->user . "" . $this->password) . "</auth>");
             } else {
                 $this->sendXML("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>");
             }
         }
     });
     $this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}success', function ($xml) {
         $this->authorized = true;
         $this->xml->finish();
         $this->createXMLStream();
         $this->startXMLStream();
     });
     $this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}failure', function ($xml) {
         if ($this->onConnected) {
             $this->connected = false;
             $func = $this->onConnected;
             $func($this);
             $this->onConnected = null;
         }
         $this->finish();
     });
     $this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-tls}proceed', function ($xml) {
         Daemon::log("XMPPClient: TLS not supported.");
     });
     $this->xml->addXPathHandler('{jabber:client}message', function ($xml) {
         if (isset($xml->attrs['type'])) {
             $payload['type'] = $xml->attrs['type'];
         } else {
             $payload['type'] = 'chat';
         }
         $payload['xml'] = $xml;
         $payload['from'] = $xml->attrs['from'];
         if ($xml->hasSub('body')) {
             $payload['body'] = $xml->sub('body')->data;
             $this->event('message', $payload);
         }
     });
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:69,代码来源:Connection.php


示例12: read

 /**
  * Read from shared memory
  * @param  integer $offset Offset
  * @param  integer $length Length
  * @return string          Data
  */
 public function read($offset, $length = 1)
 {
     $ret = '';
     $segno = floor($offset / $this->segsize);
     $sOffset = $offset % $this->segsize;
     while (true) {
         if (!isset($this->segments[$segno])) {
             if (!$this->open($segno)) {
                 goto ret;
             }
         }
         $ret .= shmop_read($this->segments[$segno], $sOffset, min($length - mb_orig_strlen($ret), $this->segsize));
         if (mb_orig_strlen($ret) >= $length) {
             goto ret;
         }
         ++$segno;
         $sOffset = 0;
     }
     ret:
     return $ret === '' ? false : $ret;
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:27,代码来源:ShmEntity.php


示例13: sendChunk

 /**
  * Sends a chunk
  * @param  object $req Request
  * @param  string $chunk Data
  * @return bool
  */
 public function sendChunk($req, $chunk)
 {
     $packet = "" . "" . pack('nn', $req->attrs->id, mb_orig_strlen($chunk)) . "" . "";
     // reserved
     return $this->write($packet) && $this->write($chunk);
     // content
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:13,代码来源:Connection.php


示例14: _get_xml_chunk_mb_orig

 public function _get_xml_chunk_mb_orig($fp)
 {
     if ($this->buf_position >= $this->buf_len) {
         if (!feof($fp)) {
             $this->buf = fread($fp, $this->read_size);
             $this->buf_position = 0;
             $this->buf_len = mb_orig_strlen($this->buf);
         } else {
             return false;
         }
     }
     //Skip line delimiters (ltrim)
     $xml_position = mb_orig_strpos($this->buf, "<", $this->buf_position);
     while ($xml_position === $this->buf_position) {
         $this->buf_position++;
         $this->file_position++;
         //Buffer ended with white space so we can refill it
         if ($this->buf_position >= $this->buf_len) {
             if (!feof($fp)) {
                 $this->buf = fread($fp, $this->read_size);
                 $this->buf_position = 0;
                 $this->buf_len = mb_orig_strlen($this->buf);
             } else {
                 return false;
             }
         }
         $xml_position = mb_orig_strpos($this->buf, "<", $this->buf_position);
     }
     //Let's find next line delimiter
     while ($xml_position === false) {
         $next_search = $this->buf_len;
         //Delimiter not in buffer so try to add more data to it
         if (!feof($fp)) {
             $this->buf .= fread($fp, $this->read_size);
             $this->buf_len = mb_orig_strlen($this->buf);
         } else {
             break;
         }
         //Let's find xml tag start
         $xml_position = mb_orig_strpos($this->buf, "<", $next_search);
     }
     if ($xml_position === false) {
         $xml_position = $this->buf_len + 1;
     }
     $len = $xml_position - $this->buf_position;
     $this->file_position += $len;
     $result = mb_orig_substr($this->buf, $this->buf_position, $len);
     $this->buf_position = $xml_position;
     return $result;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:50,代码来源:cml2.php


示例15: mask

 /**
  * Apply mask
  * @param $data
  * @param string|false $mask
  * @return mixed
  */
 public function mask($data, $mask)
 {
     for ($i = 0, $l = mb_orig_strlen($data), $ml = mb_orig_strlen($mask); $i < $l; $i++) {
         $data[$i] = $data[$i] ^ $mask[$i % $ml];
     }
     return $data;
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:13,代码来源:V13.php


示例16: stringIdx

 /**
  * Returns the character at index $idx in $str in constant time
  * @param  string $str String
  * @param  integer $idx Index
  * @return string
  */
 public static function stringIdx($str, $idx)
 {
     // FIXME: Make the const-time hack below work for all integer sizes, or
     // check it properly
     $l = mb_orig_strlen($str);
     if ($l > 65535 || $idx > $l) {
         return false;
     }
     $r = 0;
     for ($i = 0; $i < $l; ++$i) {
         $x = $i ^ $idx;
         $mask = ((($x | $x >> 16) & 0xffff) + 0xffff >> 16) - 1;
         $r |= ord($str[$i]) & $mask;
     }
     return chr($r);
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:22,代码来源:Crypt.php


示例17: onRead

 /**
  * onRead
  * @return void
  */
 protected function onRead()
 {
     if (!$this->policyReqNotFound) {
         $d = $this->drainIfMatch("<policy-file-request/>");
         if ($d === null) {
             // partially match
             return;
         }
         if ($d) {
             $FP = \PHPDaemon\Servers\FlashPolicy\Pool::getInstance($this->pool->config->fpsname->value, false);
             if ($FP && $FP->policyData) {
                 $this->write($FP->policyData . "");
             }
             $this->finish();
             return;
         } else {
             $this->policyReqNotFound = true;
         }
     }
     start:
     if ($this->finished) {
         return;
     }
     if ($this->state === self::STATE_ROOT) {
         if ($this->req !== null) {
             // we have to wait the current request
             return;
         }
         if (!($this->req = $this->newRequest())) {
             $this->finish();
             return;
         }
         $this->state = self::STATE_FIRSTLINE;
     } else {
         if (!$this->req || $this->state === self::STATE_PROCESSING) {
             if (isset($this->bev) && $this->bev->input->length > 0) {
                 Daemon::log('Unexpected input (HTTP request, ' . $this->state . '): ' . json_encode($this->read($this->bev->input->length)));
             }
             return;
         }
     }
     if ($this->state === self::STATE_FIRSTLINE) {
         if (!$this->httpReadFirstline()) {
             return;
         }
         Timer::remove($this->keepaliveTimer);
         $this->state = self::STATE_HEADERS;
     }
     if ($this->state === self::STATE_HEADERS) {
         if (!$this->httpReadHeaders()) {
             return;
         }
         if (!$this->httpProcessHeaders()) {
             $this->finish();
             return;
         }
         $this->state = self::STATE_CONTENT;
     }
     if ($this->state === self::STATE_CONTENT) {
         if (!isset($this->req->attrs->input) || !$this->req->attrs->input) {
             $this->finish();
             return;
         }
         $this->req->attrs->input->readFromBuffer($this->bev->input);
         if (!$this->req->attrs->input->isEOF()) {
             return;
         }
         $this->state = self::STATE_PROCESSING;
         if ($this->freedBeforeProcessing) {
             $this->freeRequest($this->req);
             $this->freedBeforeProcessing = false;
             goto start;
         }
         $this->freezeInput();
         if ($this->req->attrs->inputDone && $this->req->attrs->paramsDone) {
             if ($this->pool->variablesOrder === null) {
                 $this->req->attrs->request = $this->req->attrs->get + $this->req->attrs->post + $this->req->attrs->cookie;
             } else {
                 for ($i = 0, $s = mb_orig_strlen($this->pool->variablesOrder); $i < $s; ++$i) {
                     $char = $this->pool->variablesOrder[$i];
                     if ($char === 'G') {
                         if (is_array($this->req->attrs->get)) {
                             $this->req->attrs->request += $this->req->attrs->get;
                         }
                     } elseif ($char === 'P') {
                         if (is_array($this->req->attrs->post)) {
                             $this->req->attrs->request += $this->req->attrs->post;
                         }
                     } elseif ($char === 'C') {
                         if (is_array($this->req->attrs->cookie)) {
                             $this->req->attrs->request += $this->req->attrs->cookie;
                         }
                     }
                 }
             }
             Daemon::$process->timeLastActivity = time();
//.........这里部分代码省略.........
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:101,代码来源:Connection.php


示例18: parseMultipart

 /**
  * Parses multipart
  * @return void
  */
 public function parseMultipart()
 {
     start:
     if ($this->frozen) {
         return;
     }
     if ($this->state === self::STATE_SEEKBOUNDARY) {
         // seek to the nearest boundary
         if (($p = $this->search('--' . $this->boundary . "\r\n")) === false) {
             return;
         }
         // we have found the nearest boundary at position $p
         if ($p > 0) {
             $extra = $this->read($p);
             if ($extra !== "\r\n") {
                 $this->log('parseBody(): SEEKBOUNDARY: got unexpected data before boundary (length = ' . $p . '): ' . Debug::exportBytes($extra));
             }
         }
         $this->drain(mb_orig_strlen($this->boundary) + 4);
         // drain
         $this->state = self::STATE_HEADERS;
     }
     if ($this->state === self::STATE_HEADERS) {
         // parse the part's headers
         $this->curPartDisp = false;
         $i = 0;
         do {
             $l = $this->readline(\EventBuffer::EOL_CRLF);
             if ($l === null) {
                 return;
             }
             if ($l === '') {
                 break;
             }
             $e = explode(':', $l, 2);
             $e[0] = strtr(strtoupper($e[0]), Generic::$htr);
             if (isset($e[1])) {
                 $e[1] = ltrim($e[1]);
             }
             if ($e[0] === 'CONTENT_DISPOSITION' && isset($e[1])) {
                 Generic::parseStr($e[1], $this->curPartDisp, true);
                 if (!isset($this->curPartDisp['form-data'])) {
                     break;
                 }
                 if (!isset($this->curPartDisp['name'])) {
                     break;
                 }
                 $this->curPartDisp['name'] = trim($this->curPartDisp['name'], '"');
                 $name = $this->curPartDisp['name'];
                 if (isset($this->curPartDisp['filename'])) {
                     $this->curPartDisp['filename'] = trim($this->curPartDisp['filename'], '"');
                     if (!ini_get('file_uploads')) {
                         break;
                     }
                     $this->req->attrs->files[$name] = ['name' => $this->curPartDisp['filename'], 'type' => '', 'tmp_name' => null, 'fp' => null, 'error' => UPLOAD_ERR_OK, 'size' => 0];
                     $this->curPart =& $this->req->attrs->files[$name];
                     $this->req->onUploadFileStart($this);
                     $this->state = self::STATE_UPLOAD;
                 } else {
                     $this->curPart =& $this->req->attrs->post[$name];
                     $this->curPart = '';
                 }
             } elseif ($e[0] === 'CONTENT_TYPE' && isset($e[1])) {
                 if (isset($this->curPartDisp['name']) && isset($this->curPartDisp['filename'])) {
                     $this->curPart['type'] = $e[1];
                 }
             }
         } while ($i++ < 10);
         if ($this->state === self::STATE_HEADERS) {
             $this->state = self::STATE_BODY;
         }
         goto start;
     }
     if ($this->state === self::STATE_BODY || $this->state === self::STATE_UPLOAD) {
         // process the body
         $chunkEnd1 = $this->search("\r\n--" . $this->boundary . "\r\n");
         $chunkEnd2 = $this->search("\r\n--" . $this->boundary . "--\r\n");
         if ($chunkEnd1 === false && $chunkEnd2 === false) {
             /*  we have only piece of Part in buffer */
             $l = $this->length - mb_orig_strlen($this->boundary) - 8;
             if ($l <= 0) {
                 return;
             }
             if ($this->state === self::STATE_BODY && isset($this->curPartDisp['name'])) {
                 $this->curPart .= $this->read($l);
             } elseif ($this->state === self::STATE_UPLOAD && isset($this->curPartDisp['filename'])) {
                 $this->curPart['size'] += $l;
                 if ($this->req->getUploadMaxSize() < $this->curPart['size']) {
                     $this->curPart['error'] = UPLOAD_ERR_INI_SIZE;
                     $this->req->header('413 Request Entity Too Large');
                     $this->req->out('');
                     $this->req->finish();
                 } elseif ($this->maxFileSize && $this->maxFileSize < $this->curPart['size']) {
                     $this->curPart['error'] = UPLOAD_ERR_FORM_SIZE;
                     $this->req->header('413 Request Entity Too Large');
                     $this->req->out('');
//.........这里部分代码省略.........
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:101,代码来源:Input.php


示例19: sendCommand

 /**
  * Send a command
  *
  * @param $commandName
  * @param $payload
  * @param callable $cb = null
  */
 public function sendCommand($commandName, $payload, $cb = null)
 {
     $pct = implode(static::ARGS_DELIMITER, array_map(function ($item) {
         return !is_scalar($item) ? serialize($item) : $item;
     }, (array) $payload));
     $this->onResponse->push($cb);
     $this->write(pack(static::HEADER_WRITE_FORMAT, static::MAGIC_REQUEST, $this->requestCommandList[$commandName], mb_orig_strlen($pct)));
     $this->write($pct);
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:16,代码来源:Connection.php


示例20: get

 /**
  * Gets the host information
  * @param  string $hostname Hostname
  * @param  callable $cb Callback
  * @callback $cb ( )
  * @return void
  */
 public function get($hostname, $cb)
 {
     $this->onResponse->push($cb);
     $this->setFree(false);
     $e = explode(':', $hostname, 3);
     $hostname = $e[0];
     $qtype = isset($e[1]) ? $e[1] : 'A';
     $qclass = isset($e[2]) ? $e[2] : 'IN';
     $QD = [];
     $qtypeInt = array_search($qtype, Pool::$type, true);
     $qclassInt = array_search($qclass, Pool::$class, true);
     if ($qtypeInt === false || $qclassInt === false) {
         $cb(false);
         return;
     }
     $q = Binary::labels($hostname) . Binary::word($qtypeInt) . Binary::word($qclassInt);
     $QD[] = $q;
     $packet = Binary::word(++$this->seq) . Binary::bitmap2bytes('0' . '0000' . '0' . '0' . '1' . '0' . '000' . '0000', 2) . Binary::word(sizeof($QD)) . Binary::word(0) . Binary::word(0) . Binary::word(0) . implode('', $QD);
     if ($this->type === 'udp') {
         $this->write($packet);
     } else {
         $this->write(Binary::word(mb_orig_strlen($packet)) . $packet);
     }
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:31,代码来源:Connection.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mb_orig_strpos函数代码示例发布时间:2022-05-15
下一篇:
PHP mb_ord函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap