本文整理匯總了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;
}