本文整理汇总了PHP中IoC::construct方法的典型用法代码示例。如果您正苦于以下问题:PHP IoC::construct方法的具体用法?PHP IoC::construct怎么用?PHP IoC::construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IoC
的用法示例。
在下文中一共展示了IoC::construct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
public function post($post_data, $timeout = 5)
{
$cookie_file = $this->_cookie->file;
$ch = curl_init();
$header = $this->_header;
$header['Content-Type'] = 'application/json';
curl_setopt_array($ch, [CURLOPT_COOKIEJAR => $cookie_file, CURLOPT_COOKIEFILE => $cookie_file, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_URL => $this->_url, CURLOPT_AUTOREFERER => false, CURLOPT_FOLLOWLOCATION => false, CURLOPT_CONNECTTIMEOUT => $timeout, CURLOPT_TIMEOUT => $timeout, CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'] ?: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)', CURLOPT_HTTPHEADER => $header]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
\Gini\Logger::of('core')->debug('RPC => {url}: {data}', ['url' => $this->_url, 'data' => $post_data]);
$data = curl_exec($ch);
$errno = curl_errno($ch);
if ($errno) {
$message = curl_error($ch);
curl_close($ch);
\Gini\Logger::of('core')->error('RPC cURL error: {message}', ['message' => $message]);
throw IoC::construct('\\Gini\\RPC\\Exception', "transport error: {$message}", -32300);
}
curl_close($ch);
return $data;
}
示例2: enableCookie
public function enableCookie()
{
$this->_cookie = IoC::construct('\\Gini\\HTTP\\Cookie');
return $this;
}