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 )!