本文整理汇总了PHP中GeSHi::enable_ids方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::enable_ids方法的具体用法?PHP GeSHi::enable_ids怎么用?PHP GeSHi::enable_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeSHi
的用法示例。
在下文中一共展示了GeSHi::enable_ids方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGeSHI
/**
* Get a geshi object for this source. This function is for internal use.
* @return GeSHI! The geshi object associated with the source.
*/
protected function getGeSHI()
{
if (!isset($this->geshi)) {
// truncante long lines and limit the number of lines
$text = "";
$linesTruncated = array();
$lines = explode("\n", $this->plainSourceCode);
$nbOfLines = count($lines);
$n = 0;
while ($n < $nbOfLines && $n < MAX_NB_OF_LINES) {
$line = $lines[$n];
if (strlen($line) > MAX_LINE_LENGTH) {
$msg = "line #" . ($n + 1) . " has been truncated to " . MAX_LINE_LENGTH . " characters (out of " . strlen($line) . " characters)\n";
$lines[$n] = substr($lines[$n], 0, MAX_LINE_LENGTH) . "... TRUNCATED";
trigger_error($msg);
}
$text .= $line . "\n";
$n++;
}
if (count($linesTruncated)) {
$text = "WARNING: Some long lines have been truncated." . "The file might not display correcly\n" . $text;
}
$text = implode("\n", $lines);
if ($nbOfLines > MAX_NB_OF_LINES) {
$msg = "\nFILE truncated to " . MAX_NB_OF_LINES . " lines (out of " . $nbOfLines . " lines)\n";
$text .= $msg;
trigger_error($msg);
}
$geshi = new GeSHi();
$geshi->set_source($text);
$geshi->set_language($this->geshiLanguage);
$geshi->set_overall_id($this->sourceId);
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$geshi->enable_classes();
$geshi->enable_ids(true);
$this->geshi = $geshi;
}
return $this->geshi;
}