How To Print Special Charactor In <Pre> Tag By Cdetailview

i want to display the math equation using mathjax and generate a latex code of the equation below.

view.php




$this->widget('zii.widgets.CDetailView', array(

	'data'=>$model,

	'attributes'=>array(

                array(

                    'label'=>'equation',

                    'type'=>'html',

                    'value'=>$model->equation,

                ),

                array(

                    'label'=>'$\TeX$ code',

                    'type'=>'raw',

                    'value'=>'<pre>'.CHtml::encode($model->equation).'</pre>'

                ),

	),

)); ?>



model/equation.php




class Equation extends CActiveRecord

{

...

}



controller/ProblemController.php




...

	public function actionView($id)

	{       $equation=$this->loadModel($id);

                $this->render('view',array(

                    'model'=>$problem,

                ));


	}

...



equation table




id    equation

1     $x^2=2$

2     $360^\circ=2\pi$

3     $1\text{rad}=57^\circ 17' 45''$



the equation outputs works fine with mathjax but the apostrophe in tex code becomes &#039.

it is expected to show $1\text{rad}=57^\circ 17’ 45’’$

but it appears to be




$1\text{rad}=57^\circ 17&#039 45&#039&#039$



the same question appears here.

You’re using CHtml::encode($model->equation), that’s how it works.

Maybe you should remove it like you did for first column?..

thank you for your advice, when removed the CHtml::encode it shows nothing…