CKEditor使用说明

CKEditor 下载地址:http://ckeditor.com/download;php

原FCKEditor,支持java,php,asp等; 这儿用的老版本的FCKEditor,新版本都是js调用,再也不给php的了,有用试了来补上。html

先导入fckeditor.php,这个文件简单的判断了下当前server上的php版本,java

if(version_compare(phpversion(),"5","<")){编辑器

*.php4.phppost

}else{this

*.php5.phpspa

}orm

version_compare 比较先后两个版本的大小,若是当前版本小于5,会用php4那套。
server

从压缩包中去除editor文件夹,放在目录中,我放在editor中了,怕之后会加别的编辑器。htm

include 'editor/fckeditor.php'; #引入fckeditor.php 文件;

$ed = new FCKeditor("about"); #实例化;

public function __construct( $instanceName )
 	{
		$this->InstanceName	= $instanceName ;
		$this->BasePath		= '/fckeditor/' ;
		$this->Width		= '100%' ;
		$this->Height		= '200' ;
		$this->ToolbarSet	= 'Default' ;
		$this->Value		= '' ;

		$this->Config		= array() ;
	}

 InstanceName是获取时的name名称;basePath是找编辑器窗体的路径;value是初始值;ToolbarSet 能够选默认或者精简;

$bPath = $_SERVER['PHP_SELF'];
$bPath = dirname($bPath)."/editor/";
//$ed->ToolbarSet = "";
$ed->BasePath = $bPath;

basePath 指明了fckeditor.html这个文件的路径,注意,这个路径里会自带一个 editor/fckediotr.html的路径;

<form action="TEST.php"  method="post" >
<INPUT type="text" name="newtitle" value="" placeholder="请输入标题">
<?php
$ed->Create();  经过create方法,建立一个富文本框;
?>
<INPUT type="submit" value="提交" name ="SUB">
</form>

if(@$_POST['SUB']){
$title = $_POST['newtitle'];
$content = $_POST['about'];
echo $title;
echo $content;
}

获取输入的内容。

相关文章
相关标签/搜索