當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Dispatcher::getStatus方法代碼示例

本文整理匯總了PHP中Dispatcher::getStatus方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dispatcher::getStatus方法的具體用法?PHP Dispatcher::getStatus怎麽用?PHP Dispatcher::getStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Dispatcher的用法示例。


在下文中一共展示了Dispatcher::getStatus方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: framework_exception_handler

/**
 * Provides a nice print out of the stack trace when an exception is thrown.
 *
 * @param Exception $e Exception object.
 */
function framework_exception_handler($e)
{
    if (!DEBUG) {
        page_not_found();
    }
    echo '<style>h1,h2,h3,p,td {font-family:Verdana; font-weight:lighter;}</style>';
    echo '<p>Uncaught ' . get_class($e) . '</p>';
    echo '<h1>' . $e->getMessage() . '</h1>';
    $traces = $e->getTrace();
    if (count($traces) > 1) {
        echo '<p><b>Trace in execution order:</b></p>' . '<pre style="font-family:Verdana; line-height: 20px">';
        $level = 0;
        foreach (array_reverse($traces) as $trace) {
            ++$level;
            if (isset($trace['class'])) {
                echo $trace['class'] . '&rarr;';
            }
            $args = array();
            if (!empty($trace['args'])) {
                foreach ($trace['args'] as $arg) {
                    if (is_null($arg)) {
                        $args[] = 'null';
                    } else {
                        if (is_array($arg)) {
                            $args[] = 'array[' . sizeof($arg) . ']';
                        } else {
                            if (is_object($arg)) {
                                $args[] = get_class($arg) . ' Object';
                            } else {
                                if (is_bool($arg)) {
                                    $args[] = $arg ? 'true' : 'false';
                                } else {
                                    if (is_int($arg)) {
                                        $args[] = $arg;
                                    } else {
                                        $arg = htmlspecialchars(substr($arg, 0, 64));
                                        if (strlen($arg) >= 64) {
                                            $arg .= '...';
                                        }
                                        $args[] = "'" . $arg . "'";
                                    }
                                }
                            }
                        }
                    }
                }
            }
            echo '<b>' . $trace['function'] . '</b>(' . implode(', ', $args) . ')  ';
            echo 'on line <code>' . (isset($trace['line']) ? $trace['line'] : 'unknown') . '</code> ';
            echo 'in <code>' . (isset($trace['file']) ? $trace['file'] : 'unknown') . "</code>\n";
            echo str_repeat("   ", $level);
        }
        echo '</pre>';
    }
    echo "<p>Exception was thrown on line <code>" . $e->getLine() . "</code> in <code>" . $e->getFile() . "</code></p>";
    $dispatcher_status = Dispatcher::getStatus();
    $dispatcher_status['request method'] = get_request_method();
    debug_table($dispatcher_status, 'Dispatcher status');
    if (!empty($_GET)) {
        debug_table($_GET, 'GET');
    }
    if (!empty($_POST)) {
        debug_table($_POST, 'POST');
    }
    if (!empty($_COOKIE)) {
        debug_table($_COOKIE, 'COOKIE');
    }
    debug_table($_SERVER, 'SERVER');
}
開發者ID:chaobj001,項目名稱:tt,代碼行數:74,代碼來源:Framework.php

示例2:

<html>
<head>
  <title>404 Not Found</title>
</head>
<body>
  <h1>Not Found</h1>
  <p>The requested URL <?php 
echo Dispatcher::getStatus('requested_url');
?>
 was not found on this server.</p>
  <hr/>
  <address>KISS 'Keep It Simple, Stupid'</address>
</body>
</html>

<!--
   - Unfortunately, Microsoft has added a clever new 'feature' to Internet Explorer. 
   - If the text of an error's message is 'too small', specifically less than 512 bytes, 
   - Internet Explorer returns its own error message. You can turn that off, but it's 
   - pretty tricky to find switch called 'smart error messages'. That means, of course,
   - that short error messages are censored by default.
   - 
   - The workaround is pretty simple: pad the error message with a big comment like this 
   - to push it over the five hundred and twelve bytes minimum. Of course, that's exactly 
   - what you're reading right now.
   -->
開發者ID:albertobraschi,項目名稱:toad,代碼行數:26,代碼來源:404.php


注:本文中的Dispatcher::getStatus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。