Ckeditor:如何在mysql中避免使用Ckeditor中的html标签来节省时间

Ckeditor: how to avoid html tags in ckeditor on save time in mysql

本文关键字:Ckeditor 中的 html 标签 节省时间 mysql      更新时间:2024-06-29

我的小型web项目使用的是ckeditor(使用的是yii Framework),但当我编辑一个内容或创建一个新内容时,它会自动添加Html标记,并节省时间,还可以自动保存在mysql DB中的Html标记。如何在没有HTML标记的情况下存储?我该如何删除它?

EX:在CKeditor中输入:welcome

在DB输出中:<p>welcome</p>

我想删除在数据库中存储时间的html标签。

这是我的代码

<div class="control-group">
    <?php echo $form->labelEx($model, 'template_email', array('class' => 'control-label')); ?>
     <div class="controls"> 
<?php echo $form->textArea($model, 'template_email', array('rows' => 6, 'cols' => 50, 'id'=>'editor1')); ?> 
    </div>
 </div>

编写脚本

CKEDITOR.replace( 'editor1' );

控制器

public function actionCreate()
{ if(isset($_POST['CrmSettings']))
{$model->attributes=$_POST['CrmSettings'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
}
}

我该如何解决此问题?

在表中插入数据时可以使用strip_tags()

您可以在PHP.net 上查看文档