溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么在php項(xiàng)目中調(diào)用百度UEditor

發(fā)布時(shí)間:2021-03-02 17:04:50 來源:億速云 閱讀:137 作者:Leah 欄目:開發(fā)技術(shù)

這篇文章將為大家詳細(xì)講解有關(guān)怎么在php項(xiàng)目中調(diào)用百度UEditor,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。

1.首先 到官網(wǎng)下載,這個(gè)不多說。下載后解壓到網(wǎng)站你想要的目錄,我這里放到根目錄下在你需要使用編輯器的地方,插入如下HTML代碼:

<!-- 加載編輯器的容器 -->
<!-- 以下腳本中增加文本為初始化內(nèi)容 -->
  <script id="container" name="sb_remarks" type="text/plain" >
<p>
  <strong><span >備注:</span></strong>
</p>
<p>
  <br/>
</p>  
  </script>
  <!-- 配置文件 -->
  <script type="text/javascript" src="./ueditor/ueditor.config.js"></script>
  <!-- 編輯器源碼文件 -->
  <script type="text/javascript" src="./ueditor/ueditor.all.js"></script>
  <!-- 實(shí)例化編輯器 -->
  <script type="text/javascript">
    var ue = UE.getEditor('container');
  </script>

 2.調(diào)用傳值

只需在php文件中,加入一句

$sb_remarks=$_POST['sb_remarks'];

 ================================

下面是我的完整事例代碼:

index.html:

<!doctype html>
<html lang="en">
 <head>
 <meta charset="UTF-8">
 <meta name="Generator" content="EditPlus&reg;">
 <meta name="Author" content="">
 <meta name="Keywords" content="">
 <meta name="Description" content="">
 <title>設(shè)備檔案</title>
 </head>
 <body>
<form method="post" action="s.php" name="search" />
<input name="search" type="text" value="" size="15" /> 
<input type="submit" value="Search" />
</form>
<br/>
<hr/>
添加設(shè)備
<div>
 <form action="sb_add.php" method="post">
設(shè)備名稱:<input type="text" name="sb_name" /><br/>
編碼型號(hào):<input type="text" name="sb_numandtype" /><br/>
生產(chǎn)廠家:<input type="text" name="sb_home" /><br/>
啟用日期:<input type="text" name="sb_usedate" /><br/>
安裝位置:<input type="text" name="sb_address" /><br/>
<!--更新日期:<input type="text" name="sb_updatetime" /><br/>-->
<!--
<input type="text" name="sb_remarks" />
-->
<!-- 加載編輯器的容器 -->
<!-- 以下腳本中增加文本為初始化內(nèi)容 -->
  <script id="container" name="sb_remarks" type="text/plain" >
<p>
  <strong><span >備注:</span></strong>
</p>
<p>
  <br/>
</p>  
  </script>
  <!-- 配置文件 -->
  <script type="text/javascript" src="./ueditor/ueditor.config.js"></script>
  <!-- 編輯器源碼文件 -->
  <script type="text/javascript" src="./ueditor/ueditor.all.js"></script>
  <!-- 實(shí)例化編輯器 -->
  <script type="text/javascript">
    var ue = UE.getEditor('container');
  </script>
<br/>
<br/>
<input type="submit" value="添加" />
</form>
</div>
 </body>
</html>

 sb_add.php

<?php
$con = mysql_connect("localhost","root","110");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }
mysql_query("set names 'utf8'",$con);
mysql_select_db("bzec", $con);
 
$sb_name=$_POST['sb_name'];
$sb_numandtype=$_POST['sb_numandtype'];
$sb_home=$_POST['sb_home'];
$sb_usedate=$_POST['sb_usedate'];
$sb_address=$_POST['sb_address'];
//$sb_updatetime=$_POST['sb_updatetime'];
$sb_updatetime=date("Y-m-d G:i:s");
$sb_remarks=$_POST['sb_remarks'];
 
//$nikename= trim($nikename);
 
/* 
if (!$nikename || !$email) //判斷是否為空
{
echo '不能為空';
exit;
}
*/
 
$sql="INSERT INTO shebeidangan (sb_name,sb_numandtype,sb_home,sb_usedate,sb_address,sb_updatetime,sb_remarks)
VALUES
('$sb_name','$sb_numandtype','$sb_home','$sb_usedate','$sb_address','$sb_updatetime','$sb_remarks')";
  
  
if (!mysql_query($sql,$con))
 {
 die('Error: ' . mysql_error());
 }
echo "ADD OK";
  
mysql_close($con)
?>

 3.如果要修改 編輯器默認(rèn)字體大小的話,在編輯器UEditor目錄,ueditor.all.js文件里面查找“字體” ,就可以找到修改字號(hào)和字體的地方

關(guān)于怎么在php項(xiàng)目中調(diào)用百度UEditor就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI