本文整理汇总了PHP中Kohana_Exception::debug_source方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana_Exception::debug_source方法的具体用法?PHP Kohana_Exception::debug_source怎么用?PHP Kohana_Exception::debug_source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kohana_Exception
的用法示例。
在下文中一共展示了Kohana_Exception::debug_source方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
<li class="snippet">
<p>
<span class="file">
<?php
echo Kohana_Exception::debug_path($file);
?>
[ <?php
echo $line;
?>
]
</span>
</p>
<div class="source">
<?php
if (Kohana_Exception::$source_output and $source_code = Kohana_Exception::debug_source($file, $line)) {
?>
<code><?php
foreach ($source_code as $num => $row) {
?>
<span class="line <?php
echo $num == $line ? "highlight" : "";
?>
"><span class="number"><?php
echo $num;
?>
</span><?php
echo htmlspecialchars($row, ENT_NOQUOTES, Kohana::CHARSET);
?>
</span><?php
}
示例2: trace
/**
* Returns an array of strings that represent each step in the backtrace.
*
* @param array trace to analyze
* @return array
*/
public static function trace($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 = Kohana_Exception::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 ($step['function'] === '{closure}') {
// Introspection on closures 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;
}
示例3: if
<ol class="trace">
<li class="snippet">
<p>
<span class="file">
<?php
echo Kohana_Exception::debug_path($file);
?>
[ <?php
echo $line;
?>
]
</span>
</p>
<div class="source">
<? if (Kohana_Exception::$source_output and $source_code = Kohana_Exception::debug_source($file, $line)): ?><code><? foreach ($source_code as $num => $row): ?><span class="line <?php
echo $num == $line ? "highlight" : "";
?>
"><span class="number"><?php
echo $num;
?>
</span><?php
echo htmlspecialchars($row, ENT_NOQUOTES, Kohana::CHARSET);
?>
</span><? endforeach ?></code>
<? endif ?>
</div>
</li>
<? if (Kohana_Exception::$trace_output): ?>
<? foreach (Kohana_Exception::trace($trace) as $i => $step): ?>