本文整理汇总了PHP中Std::random方法的典型用法代码示例。如果您正苦于以下问题:PHP Std::random方法的具体用法?PHP Std::random怎么用?PHP Std::random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Std
的用法示例。
在下文中一共展示了Std::random方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: customRequest
public function customRequest($post, $api, $sock = null, $method = null)
{
$url_regexp = new EReg("^(https?://)?([a-zA-Z\\.0-9-]+)(:[0-9]+)?(.*)\$", "");
if (!$url_regexp->match($this->url)) {
$this->onError("Invalid URL");
return;
}
$secure = $url_regexp->matched(1) === "https://";
if ($sock === null) {
if ($secure) {
$sock = new php_net_SslSocket();
} else {
$sock = new sys_net_Socket();
}
}
$host = $url_regexp->matched(2);
$portString = $url_regexp->matched(3);
$request = $url_regexp->matched(4);
if ($request === "") {
$request = "/";
}
$port = $portString === null || $portString === "" ? $secure ? 443 : 80 : Std::parseInt(_hx_substr($portString, 1, strlen($portString) - 1));
$data = null;
$multipart = _hx_field($this, "file") !== null;
$boundary = null;
$uri = null;
if ($multipart) {
$post = true;
$boundary = Std::string(Std::random(1000)) . Std::string(Std::random(1000)) . Std::string(Std::random(1000)) . Std::string(Std::random(1000));
while (strlen($boundary) < 38) {
$boundary = "-" . $boundary;
}
$b = new StringBuf();
if (null == $this->params) {
throw new HException('null iterable');
}
$»it = $this->params->keys();
while ($»it->hasNext()) {
$p = $»it->next();
$b->add("--");
$b->add($boundary);
$b->add("\r\n");
$b->add("Content-Disposition: form-data; name=\"");
$b->add($p);
$b->add("\"");
$b->add("\r\n");
$b->add("\r\n");
$b->add($this->params->get($p));
$b->add("\r\n");
}
$b->add("--");
$b->add($boundary);
$b->add("\r\n");
$b->add("Content-Disposition: form-data; name=\"");
$b->add($this->file->param);
$b->add("\"; filename=\"");
$b->add($this->file->filename);
$b->add("\"");
$b->add("\r\n");
$b->add("Content-Type: " . "application/octet-stream" . "\r\n" . "\r\n");
$uri = $b->b;
} else {
if (null == $this->params) {
throw new HException('null iterable');
}
$»it = $this->params->keys();
while ($»it->hasNext()) {
$p = $»it->next();
if ($uri === null) {
$uri = "";
} else {
$uri .= "&";
}
$uri .= rawurlencode($p) . "=" . rawurlencode($this->params->get($p));
}
}
$b = new StringBuf();
if ($method !== null) {
$b->add($method);
$b->add(" ");
} else {
if ($post) {
$b->add("POST ");
} else {
$b->add("GET ");
}
}
if (_hx_field(_hx_qtype("haxe.Http"), "PROXY") !== null) {
$b->add("http://");
$b->add($host);
if ($port !== 80) {
$b->add(":");
$b->add($port);
}
}
$b->add($request);
if (!$post && $uri !== null) {
if (_hx_index_of($request, "?", 0) >= 0) {
$b->add("&");
} else {
//.........这里部分代码省略.........