本文整理汇总了PHP中QM_Output_Html::file_link_format方法的典型用法代码示例。如果您正苦于以下问题:PHP QM_Output_Html::file_link_format方法的具体用法?PHP QM_Output_Html::file_link_format怎么用?PHP QM_Output_Html::file_link_format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QM_Output_Html
的用法示例。
在下文中一共展示了QM_Output_Html::file_link_format方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output_filename
public static function output_filename($text, $file, $line = 1)
{
# Further reading:
# http://simonwheatley.co.uk/2012/07/clickable-stack-traces/
# https://github.com/grych/subl-handler
if (!isset(self::$file_link_format)) {
$format = ini_get('xdebug.file_link_format');
$format = apply_filters('qm/output/file_link_format', $format);
if (empty($format)) {
self::$file_link_format = false;
} else {
self::$file_link_format = str_replace(array('%f', '%l'), array('%1$s', '%2$d'), $format);
}
}
if (false === self::$file_link_format) {
return $text;
}
$link = sprintf(self::$file_link_format, urlencode($file), $line);
return sprintf('<a href="%s">%s</a>', $link, $text);
}
示例2: output_filename
/**
* Returns a file path, name, and line number. Safe for output.
*
* If clickable file links are enabled, a link such as this is returned:
*
* <a href="subl://open/?line={line}&url={file}">{text}</a>
*
* Otherwise, the display text and file details such as this is returned:
*
* {text}<br>{file}:{line}
*
* @param string $text The display text, such as a function name or file name.
* @param string $file The full file path and name.
* @param int $line Optional. A line number, if appropriate.
* @return string The fully formatted file link or file name, safe for output.
*/
public static function output_filename($text, $file, $line = 0)
{
if (empty($file)) {
return esc_html($text);
}
# Further reading:
# http://simonwheatley.co.uk/2012/07/clickable-stack-traces/
# https://github.com/grych/subl-handler
$link_line = $line ? $line : 1;
if (!isset(self::$file_link_format)) {
$format = ini_get('xdebug.file_link_format');
$format = apply_filters('qm/output/file_link_format', $format);
if (empty($format)) {
self::$file_link_format = false;
} else {
self::$file_link_format = str_replace(array('%f', '%l'), array('%1$s', '%2$d'), $format);
}
}
if (false === self::$file_link_format) {
$fallback = QM_Util::standard_dir($file, '');
if ($line) {
$fallback .= ':' . $line;
}
$return = esc_html($text);
if ($fallback !== $text) {
$return .= '<br><span class="qm-info"> ' . esc_html($fallback) . '</span>';
}
return $return;
}
$link = sprintf(self::$file_link_format, urlencode($file), intval($link_line));
return sprintf('<a href="%s">%s</a>', esc_attr($link), esc_html($text));
}