当前位置: 首页>>代码示例>>PHP>>正文


PHP response::setStatus方法代码示例

本文整理汇总了PHP中response::setStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP response::setStatus方法的具体用法?PHP response::setStatus怎么用?PHP response::setStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在response的用法示例。


在下文中一共展示了response::setStatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 function run($app = 'app')
 {
     MvcApplication::$app = $app;
     Console::debugEx(LOG_VERBOSE, __CLASS__, 'Invoking router...');
     // Create new router and invoke it
     response::setStatus(200);
     $router = config::get(self::KEY_MVC_ROUTER, 'DefaultRouter');
     $r = new $router();
     $r->route();
     return 0;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:11,代码来源:mvc.php

示例2: exception

 function exception(Exception $e)
 {
     if (ob_get_length() != false) {
         @ob_end_clean();
     }
     $et = typeOf($e);
     if ($et == 'FileNotFoundException' || $et == 'NavigationException') {
         response::setStatus(404);
         header('HTTP/1.1 404 Not Found', true);
         printf("<h1>404: Not Found</h1>");
         return;
     }
     if ($et == 'HttpException') {
         response::setStatus($e->getCode());
         $code = $e->getMessage();
         list($code) = explode(':', $code);
         $code = str_replace('Error ', '', $code);
         $msg = HttpException::getHttpMessage($code);
         header('HTTP/1.1 ' . $code . ' ' . $msg . ' ' . $msg);
         printf("<h1>%s: %s</h1>\n<pre>%s</pre>", $code, $msg, $msg);
         return;
     }
     response::setStatus(500);
     logger::emerg("Unhandled exception: (%s) %s in %s:%d", get_class($e), $e->getMessage(), str_replace(BASE_PATH, '', $e->getFile()), $e->getLine());
     header('HTTP/1.1 501 Server Error', true);
     $id = uniqid();
     $dbg = sprintf("Unhandled exception: (%s) %s\n  in %s:%d", get_class($e), $e->getMessage(), str_replace(SYS_PATH, '', $e->getFile()), $e->getLine()) . Console::backtrace(0, $e->getTrace(), true) . "\n" . "Loaded modules:\n" . ModuleManager::debug() . "\n" . request::getDebugInformation();
     logger::emerg($dbg);
     if (config::get('lepton.mvc.exception.log', false) == true) {
         $logfile = config::get('lepton.mvc.exception.logfile', "/tmp/" . $_SERVER['HTTP_HOST'] . "-debug.log");
         $log = "=== Unhandled Exception ===\n\n" . $dbg . "\n";
         $lf = @fopen($logfile, "a+");
         if ($lf) {
             fputs($lf, $log);
             fclose($lf);
         }
     }
     $ico_error = resource::get('warning.png');
     header('content-type: text/html; charset=utf-8');
     echo '<html><head><title>Unhandled Exception</title>' . self::$css . self::$js . '</head><body>' . '<div id="box"><div id="left"><img src="' . $ico_error . '" width="32" height="32"></div><div id="main">' . '<h1>An Unhandled Exception Occured</h1>' . '<hr noshade>' . '<p>This means that something didn\'t go quite go as planned. This could be ' . 'caused by one of several reasons, so please be patient and try ' . 'again in a little while.</p>';
     if (config::get('lepton.mvc.exception.feedback', false) == true) {
         echo '<p>The administrator of the website has been notified about this error. You ' . 'can help us find and fix the problem by writing a line or two about what you were doing when this ' . 'error occured.</p>';
         echo '<p id="feedbacklink"><a href="javascript:doFeedback();">If you would like to assist us with more information, please click here</a>.</p>';
         echo '<div id="feedback" style="display:none;"><p>Describe in a few short lines what you were doing right before you encountered this error:</p><form action="/errorevent.feedback/' . $id . '" method="post"><div><textarea name="text" style="width:100%; height:50px;"></textarea></div><div style="padding-top:5px; text-align:right;"><input type="button" value=" Close " onclick="closeFeedback();"> <input type="submit" value=" Submit Feedback "></div></form></div>';
     }
     if (config::get('lepton.mvc.exception.showdebug', false) == true) {
         echo '<hr noshade>' . '<a href="javascript:toggleAdvanced();">Details &raquo;</a>' . '<pre id="advanced" style="display:none; height:300px;">' . $dbg . '</pre>';
     }
     echo '<div>' . '</body></html>';
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:50,代码来源:exception.php

示例3: getInstance

 public static function getInstance($controllerClassName = null)
 {
     if (self::$_instance === null && $controllerClassName !== null) {
         // autoload all dependencies before session start
         kanon::loadAllModules();
         self::$_instance = new $controllerClassName();
         response::setStatus(200);
         response::setCharset('utf-8');
         @set_magic_quotes_runtime(false);
         frontController::startSession('.' . uri::getDomainName());
         if (get_magic_quotes_gpc()) {
             frontController::_stripSlashesDeep($_GET);
             frontController::_stripSlashesDeep($_POST);
         }
         kanon::callDeferred();
         // call all deferred by modules functions
     }
     return self::$_instance;
 }
开发者ID:alexqwert,项目名称:kanon,代码行数:19,代码来源:application.php


注:本文中的response::setStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。