本文目錄一覽:
如何在php中調用ckeditor 並讀取出數據庫中的數據
你換個名字不就完了,多簡單。實在不行就替換函數,str_replace什麼的
php下怎麼使用多個ckeditor 在線編輯器
CKeditor是一款在線編輯器,可用於博客、新聞發布等的文本編輯框,利用它可以很方便地實現對文章的排版。它是一款開源工具,可以在我們的網站中使用它增強編輯功能,顯得專業和裝B。原來它叫FCKeditor,後來改名叫CKeiditor,感謝開源軟件的開發者,他們是最帥的!
一、下載
官網下載:
解壓之後直接放在網站根目錄里就可以使用了。
在_samples目錄下,可以找到很多做好的樣例,這些可以用來學習編輯器的用法。
二、用js的方式調用
官方演示樣例:
複製代碼
html
head
titleSample CKEditor Site/title
script type=”text/javascript” src=”ckeditor/ckeditor.js”/script
/head
body
form method=”post”
p
My Editor:br /
textarea id=”editor1″ name=”editor1″pInitial value./p/textarea
script type=”text/javascript”
CKEDITOR.replace( ‘editor1’ );
/script
/p
p
input type=”submit” /
/p
/form
/body
/html
複製代碼
我是把ckeditor目錄和test.html放在同個目錄下,注意第四行原來是src=”/ckeditor/ckeditor.js”,要把前面的斜杠去掉,改為src=”ckeditor/ckeditor.js”才能正確指向文件ckeditor.js。這時候不啟用wamp服務器也能正確顯示ckeditor。
三、用PHP的方法引入
複製代碼
pTitle:/pinput name=”subject” type=”text”
?php
include ‘ckeditor/ckeditor.php’; //include ckeditor.php
$ckeditor = new CKEditor;
$ckeditor-editor(‘content’);
?
input name=”submit” type=”submit” value=”提交” /
複製代碼
這樣也能引入ckeditor,這時候editor的位置就在中間那段php代碼的地方,兩種方法都可以,不過我還不明白兩種方法有什麼區別。
還可以在textarea標籤中嵌入ckeditor:
複製代碼
?php
if(!empty($_POST[“sub”]))
{
echo $_POST[“title”];
echo “br”;
echo $_POST[“content”];
}
?
html
head
titleSample CKEditor Site/title
/head
body
form method=”post”
p
My Editor:br /
input type=”text” name=”title”
textarea name=”content”
?php
include ‘ckeditor/ckeditor.php’; //include ckeditor.php
$ckeditor = new CKEditor;
$ckeditor-editor(‘content’);
?
/textarea
/p
p
input type=”submit” name=”sub”/
/p
/form
/body
/html
php怎麼調用ckeditor
將FCKeditor放在網站根目錄
在PHP文件裡面,包含/FCKeditor/ckeditor/” target=”_blank”fckeditor.php文件
在網頁中需要放置該編輯器的地方插入下面代碼即可調用:
代碼如下 複製代碼
1 ?php
//包含fckeditor類
include(“fckeditor/fckeditor.php”) ;
//創建一個FCKeditor,表單名稱為 jzleditor
$oFCKeditor = new FCKeditor(“jzleditor”);
//設置編輯器路徑
$oFCKeditor-BasePath = “fckeditor/”;
$oFCKeditor-ToolbarSet = “Default”;//工具按鈕
$oFCKeditor-Value =$cont; //;設置初始內容
$oFCKeditor-Width=”100%”; //設置它的寬度
$oFCKeditor-Height=”550px”; //設置它的高度
$oFCKeditor-Create();
我還有在後盾網學習呢,加油(ง •̀_•́)งฅ ̳͒•ˑ̫• ̳͒ฅ♡
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/160557.html