本文整理匯總了PHP中cookie::developer方法的典型用法代碼示例。如果您正苦於以下問題:PHP cookie::developer方法的具體用法?PHP cookie::developer怎麽用?PHP cookie::developer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cookie
的用法示例。
在下文中一共展示了cookie::developer方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: request
function request($type, $url, $get = [], $post = [])
{
$developer = cookie::developer();
if ($developer) {
$get['_mode'] = 'developer';
}
$request = ['method' => $type, 'protocol_version' => '1.1', 'header' => 'Connection: Close'];
foreach ($post as $name => &$param) {
if (is_array($param) and empty($param)) {
$param = '_empty_array';
}
}
if (!empty($post)) {
$request['header'] .= "\r\nContent-type: application/x-www-form-urlencoded";
$request['content'] = http_build_query($post);
}
$ctx = stream_context_create(['http' => $request]);
$response = file_get_contents($this->endpoint . (empty($get) ? $url : $url . '?' . http_build_query($get)), false, $ctx);
$object = json::decode($response, true);
if (is_null($object)) {
if ($developer) {
var_dump($response);
die;
} else {
throw new Exception("Error Processing Request", 1);
}
}
$content = $object['content'];
return (is_object($content) or is_array($content) and array_values($content) !== $content) ? (object) $content : $content;
}