本文整理汇总了PHP中SC::getResponseContentType方法的典型用法代码示例。如果您正苦于以下问题:PHP SC::getResponseContentType方法的具体用法?PHP SC::getResponseContentType怎么用?PHP SC::getResponseContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SC
的用法示例。
在下文中一共展示了SC::getResponseContentType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResponseContentType
private function getResponseContentType()
{
return SC::getResponseContentType("json");
/*
$return_types = SC::$return_types;
$accepts = explode(", ", $_SERVER["HTTP_ACCEPT"]);
foreach($return_types as $accept_type=>$response_type) {
if(in_array($accept_type, $accepts)) {
return $response_type;
}
}
return "json";
*/
}
示例2: Exception
<?php
require_once "config/environment.php";
require_once "sc_lib.php";
try {
if (strpos($_SERVER["REQUEST_URI"], "index.php") > -1) {
SC::transfer();
}
$uri = $_SERVER["REQUEST_URI"];
$route_parts = SCRoutes::parseUrl();
if (!$route_parts) {
throw new Exception("This page does not exist", 404);
}
$route_parts["__content_type"] = SC::getResponseContentType();
$_GET = array_merge($_GET, $route_parts);
//var_dump($route_parts);
$controller_file = SCBASEPATH . "/controllers/" . $route_parts["controller"] . ".php";
if (file_exists($controller_file)) {
require_once $controller_file;
if ($controller) {
if (method_exists($controller, $route_parts["action"])) {
$controller->{$route_parts}["action"]();
} else {
throw new Exception("The " . $route_parts["action"] . " action has not been defined for the " . $route_parts["controller"] . " controller.", 500);
}
} else {
throw new Exception("The " . $route_parts["controller"] . " controller has not been initialized", 500);
}
} else {
throw new Exception("The " . $route_parts["controller"] . " controller does not exist", 500);
}