PHP development framework YiiFramework tutorial (18) UI component TextHighlighter example

Source: Internet
Author: User
PHP development framework YiiFramework tutorial (18) UI component TextHighlighter example

CTextHighlighter is used to format the display code. Currently, the supported Display languages include ABAP, CPP, CSS, DIFF, DTD, HTML, JAVA, JAVASCRIPT, MYSQL, PERL, PHP, PYTHON, RUBY, SQL, XML. the line number can also be displayed when the code is displayed. the line number is displayed through showLineNumbers = TRUE.

In this example, the PHP code is displayed, with a line number and without a line number:

PHP code

BeginWidget ('ctexthighlighter ', array ('language' => 'php');?>
// Include Yii bootstrap file
// Require_once (dirname (_ FILE _). '/.../../framework/yii. php ');
$ Yii = 'C:/yiiframework/yii. php ';
// Remove the following line when in production mode
Defined ('II _ debug') or define ('II _ debug', true );

$ Config = dirname (_ FILE _). '/protected/config/main. php ';

// Remove the following line when in production mode
// Defined ('II _ debug') or define ('II _ debug', true );

Require_once ($ yii );
Yii: createWebApplication ($ config)-> run ();
EndWidget ();?>

PHP code with Line Number

BeginWidget ('ctexthighlighter ', array ('language' => 'php ',
'Showlinenumbers '=> 'true');?>
/**
* SiteController is the default controller to handle user requests.
*/
Class SiteController extends CController
{
/**
* Index action is the default action in a controller.
*/
Public function actionIndex ()
{

$ Model = new DataModel ();

If (! Emptyempty ($ _ POST [DataModel])
{
$ Model-> attributes =$ _ POST [DataModel];

If ($ model-> validate () $ success = true;

}

$ This-> render ('index', array (
'Model' => $ model,

));
}
}
EndWidget ();?>

Specify the type of the code to be displayed by specifying the language type (case insensitive.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.