本文整理汇总了PHP中Debug::source方法的典型用法代码示例。如果您正苦于以下问题:PHP Debug::source方法的具体用法?PHP Debug::source怎么用?PHP Debug::source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debug
的用法示例。
在下文中一共展示了Debug::source方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _init
public static function _init()
{
self::$time = microtime(TRUE);
self::$consoleMode = PHP_SAPI === 'cli';
self::$productionMode = self::DETECT;
if (self::$consoleMode) {
self::$source = empty($_SERVER['argv']) ? 'cli' : 'cli: ' . $_SERVER['argv'][0];
} else {
self::$firebugDetected = isset($_SERVER['HTTP_X_FIRELOGGER']);
self::$ajaxDetected = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';
if (isset($_SERVER['REQUEST_URI'])) {
self::$source = (isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https://' : 'http://') . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '')) . $_SERVER['REQUEST_URI'];
}
}
$tab = array(__CLASS__, 'renderTab');
$panel = array(__CLASS__, 'renderPanel');
self::addPanel(new DebugPanel('time', $tab, $panel));
self::addPanel(new DebugPanel('memory', $tab, $panel));
self::addPanel(new DebugPanel('errors', $tab, $panel));
self::addPanel(new DebugPanel('dumps', $tab, $panel));
}
示例2: htmlspecialchars
echo htmlspecialchars((string) $message, ENT_QUOTES, Kohana::$charset, true);
?>
</span></h1>
<div id="<?php
echo $error_id;
?>
" class="content">
<p><span class="file"><?php
echo Debug::path($file);
?>
[ <?php
echo $line;
?>
]</span></p>
<?php
echo Debug::source($file, $line);
?>
<ol class="trace">
<?php
foreach (Debug::trace($trace) as $i => $step) {
?>
<li>
<p>
<span class="file">
<?php
if ($step['file']) {
$source_id = $error_id . 'source' . $i;
?>
<a href="#<?php
echo $source_id;
?>
示例3: trace
/**
* Returns an array of HTML strings that represent each step in the backtrace.
*
* // Displays the entire current backtrace
* echo implode('<br/>', Debug::trace());
*
* @param array $trace
* @return array
*/
public static function trace(array $trace = null)
{
if ($trace === null) {
// Start a new trace
$trace = debug_backtrace();
}
// Non-standard function calls
$statements = array('include', 'include_once', 'require', 'require_once');
$output = array();
foreach ($trace as $step) {
if (!isset($step['function'])) {
// Invalid trace step
continue;
}
if (isset($step['file']) and isset($step['line'])) {
// Include the source of this step
$source = Debug::source($step['file'], $step['line']);
}
if (isset($step['file'])) {
$file = $step['file'];
if (isset($step['line'])) {
$line = $step['line'];
}
}
// function()
$function = $step['function'];
if (in_array($step['function'], $statements)) {
if (empty($step['args'])) {
// No arguments
$args = array();
} else {
// Sanitize the file path
$args = array($step['args'][0]);
}
} elseif (isset($step['args'])) {
if (!function_exists($step['function']) or strpos($step['function'], '{closure}') !== false) {
// Introspection on closures or language constructs in a stack trace is impossible
$params = null;
} else {
if (isset($step['class'])) {
if (method_exists($step['class'], $step['function'])) {
$reflection = new ReflectionMethod($step['class'], $step['function']);
} else {
$reflection = new ReflectionMethod($step['class'], '__call');
}
} else {
$reflection = new ReflectionFunction($step['function']);
}
// Get the function parameters
$params = $reflection->getParameters();
}
$args = array();
foreach ($step['args'] as $i => $arg) {
if (isset($params[$i])) {
// Assign the argument by the parameter name
$args[$params[$i]->name] = $arg;
} else {
// Assign the argument by number
$args[$i] = $arg;
}
}
}
if (isset($step['class'])) {
// Class->method() or Class::method()
$function = $step['class'] . $step['type'] . $step['function'];
}
$output[] = array('function' => $function, 'args' => isset($args) ? $args : null, 'file' => isset($file) ? $file : null, 'line' => isset($line) ? $line : null, 'source' => isset($source) ? $source : null);
unset($function, $args, $file, $line, $source);
}
return $output;
}
示例4: trace
public static function trace(array $trace = NULL)
{
if ($trace === NULL) {
// Start a new trace
$trace = debug_backtrace();
}
// Non-standard function calls
$statements = array("include", "include_once", "require", "require_once");
$output = array();
foreach ($trace as $step) {
if (!isset($step["function"])) {
// Invalid trace step
continue;
}
if (isset($step["file"]) and isset($step["line"])) {
// Include the source of this step
$source = Debug::source($step["file"], $step["line"]);
}
if (isset($step["file"])) {
$file = $step["file"];
if (isset($step["line"])) {
$line = $step["line"];
}
}
// function()
$function = $step["function"];
if (in_array($step["function"], $statements)) {
if (empty($step["args"])) {
// No arguments
$args = array();
} else {
// Sanitize the file path
$args = array($step["args"][0]);
}
} elseif (isset($step["args"])) {
if (!function_exists($step["function"]) or strpos($step["function"], "{closure}") !== FALSE) {
// Introspection on closures or language constructs in a stack trace is impossible
$params = NULL;
} else {
if (isset($step["class"])) {
if (method_exists($step["class"], $step["function"])) {
$reflection = new ReflectionMethod($step["class"], $step["function"]);
} else {
$reflection = new ReflectionMethod($step["class"], "__call");
}
} else {
$reflection = new ReflectionFunction($step["function"]);
}
// Get the function parameters
$params = $reflection->getParameters();
}
$args = array();
foreach ($step["args"] as $i => $arg) {
if (isset($params[$i])) {
// Assign the argument by the parameter name
$args[$params[$i]->name] = $arg;
} else {
// Assign the argument by number
$args[$i] = $arg;
}
}
}
if (isset($step["class"])) {
// Class->method() or Class::method()
$function = $step["class"] . $step["type"] . $step["function"];
}
$output[] = array("function" => $function, "args" => isset($args) ? $args : NULL, "file" => isset($file) ? $file : NULL, "line" => isset($line) ? $line : NULL, "source" => isset($source) ? $source : NULL);
unset($function, $args, $file, $line, $source);
}
return $output;
}
示例5: exec
*/
$cols = exec('tput cols', $status, $result);
if ($result !== 0) {
// Probably running under cron or otherwise detached from a terminal
$cols = 100;
}
// Render the exception message in a header block
$main_message = $class . ' [' . $code . ']: ' . $message;
$main_message = explode(\PHP_EOL, $main_message);
$main_message = array_map(function ($val) use($cols) {
return str_pad($val, $cols);
}, $main_message);
echo Minion_CLI::color(implode(\PHP_EOL, $main_message), 'white', 'red') . \PHP_EOL;
echo Minion_CLI::color(str_pad(Debug::path($file) . '[' . $line . ']', $cols), 'red') . \PHP_EOL;
// Render the source that failed, highlighting the failing line
$source = html_entity_decode(strip_tags(Debug::source($file, $line)));
$source = preg_replace_callback("/^" . $line . ".+?\$/m", function ($err_line) {
return Minion_CLI::color($err_line[0], 'white', 'red');
}, $source);
echo $source . \PHP_EOL;
// Render the trace
echo Minion_CLI::color(str_pad("TRACE (last 5 entries)", $cols), 'black', 'yellow') . \PHP_EOL;
$level = -1;
foreach (Debug::trace($trace) as $i => $step) {
$level++;
$file = $step['file'] ? Debug::path($step['file']) . '[' . $step['line'] . ']' : '{PHP internal call}';
echo Minion_CLI::color(str_pad("#" . $level, 3), 'black', 'yellow') . " " . Minion_CLI::color($step['function'], 'yellow') . " - " . Minion_CLI::color($file, 'cyan') . \PHP_EOL;
if (!$step['args']) {
continue;
}
$max_name_len = max(array_map(function ($key) {