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

Source: Internet
Author: User
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 showLineNumbersTRUE. 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 codebeginWidget('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 modedefined('YII_DEBUG') or define('YII_DEBUG',true);$config=dirname(__FILE__).'/protected/config/main.php';// remove the following line when in production mode// defined('YII_DEBUG') or define('YII_DEBUG',true);require_once($yii);Yii::createWebApplication($config)->run();endWidget(); ?>PHP code with Line NumberbeginWidget('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.

The above is the sample content of the UI component TextHighlighter in the PHP development Framework Yii Framework tutorial (18). For more information, see The PHP Chinese website (www.php1.cn )!

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.