PHP development framework Yii Framework tutorial (18) UI component TextHighlighter example

黄舟
Release: 2023-03-05 07:46:01
Original
1271 people have browsed it

CTextHighlighter is used to format the display code. The currently supported display languages ​​are ABAP, CPP, CSS, DIFF, DTD, HTML, JAVA, JAVASCRIPT, MYSQL, PERL, PHP, PYTHON, RUBY, SQL, XML, when displaying the code. Line numbers can also be displayed, turning on line number display via showLineNumbers=TRUE.

This example displays PHP codes, one with line numbers and one without line numbers:

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 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 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(); ?>
Copy after login

Indicate the type of code to be displayed by specifying the type of language (not case-sensitive).

PHP development framework Yii Framework tutorial (18) UI component TextHighlighter example

The above is the content of the PHP development framework Yii Framework tutorial (18) UI component TextHighlighter example. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!