Ctexthighlighter is used to format the display code, currently supports display of 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, and the line number is displayed by Showlinenumbers=true.
This example shows the PHP code, one with line numbers, and one without line numbers:
PHP code <!--? php $this--->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 production mode defined (' 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 (); <!--? php $this--->endwidget ();?> PHP code with line number <!--? php $this--->beginwidget (' Ctex Thighlighter ', Array (' Language ' => ' PHP ', ' showlinenumbers ' => ' true ');?>/** * sitecontroller is th
e 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,
)); } <!--? php $this--->endwidget ();?>
Specify the kind of code you want to display by specifying the type of language (case-insensitive).
This example downloads: Http://www.imobilebbs.com/download/yii/TextHighlighterDemo.zip
See a full set of tutorials: http://www.bianceng.cn/webkf/PHP/201301/35265.htm