當前位置: 首頁>>代碼示例>>PHP>>正文


PHP GeSHi::enable_ids方法代碼示例

本文整理匯總了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;
 }
開發者ID:GitHubTianPeng,項目名稱:101worker,代碼行數:43,代碼來源:megalib_leftover.php


注:本文中的GeSHi::enable_ids方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。