本文整理汇总了PHP中CMbString::diff_html方法的典型用法代码示例。如果您正苦于以下问题:PHP CMbString::diff_html方法的具体用法?PHP CMbString::diff_html怎么用?PHP CMbString::diff_html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMbString
的用法示例。
在下文中一共展示了CMbString::diff_html方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatDiffAsHTML
static function formatDiffAsHTML($before, $after, $mode = "w")
{
if (!self::diff($before, $after, $mode)) {
return false;
}
$html = '';
$td = count(self::$diff);
for ($d = 0; $d < $td; ++$d) {
$diff = self::$diff[$d];
switch ($diff['change']) {
case '=':
$html .= nl2br(htmlSpecialChars(substr($before, $diff['position'], $diff['length'])));
break;
case '-':
$html .= '<del class="diff">' . nl2br(htmlSpecialChars(substr($before, $diff['position'], $diff['length']))) . '</del>';
break;
case '+':
$html .= '<ins class="diff">' . nl2br(htmlSpecialChars(substr($after, $diff['position'], $diff['length']))) . '</ins>';
break;
default:
self::$error = $diff['change'] . ' is not an expected difference change type';
return false;
}
}
return self::$diff_html = self::purifyHTML($html);
}