当前位置: 首页>>代码示例>>PHP>>正文


PHP misc::remove_nbsp方法代码示例

本文整理汇总了PHP中misc::remove_nbsp方法的典型用法代码示例。如果您正苦于以下问题:PHP misc::remove_nbsp方法的具体用法?PHP misc::remove_nbsp怎么用?PHP misc::remove_nbsp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在misc的用法示例。


在下文中一共展示了misc::remove_nbsp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createAction

 /**
  * 新建文章
  * @author cms
  */
 public function createAction()
 {
     //栏目
     $data['category'] = $this->db_category->categoryList();
     if ($this->getRequest()->isPost()) {
         $continue = TRUE;
         //缩略图
         if ($_FILES['defaultpic']['name']) {
             //相对路径
             $dir = 'upload' . DIRECTORY_SEPARATOR . 'news' . DIRECTORY_SEPARATOR . date('Y', $_SERVER['REQUEST_TIME']) . DIRECTORY_SEPARATOR . date('m', $_SERVER['REQUEST_TIME']) . DIRECTORY_SEPARATOR . date('d', $_SERVER['REQUEST_TIME']);
             //绝对路径
             $path = APP_PATH . DIRECTORY_SEPARATOR . 'kele' . DIRECTORY_SEPARATOR . $dir;
             if (!is_dir($path)) {
                 $continue = mkdir($path, 0777, true);
             }
             if ($continue) {
                 $continue = move_uploaded_file($_FILES['defaultpic']['tmp_name'], $path . DIRECTORY_SEPARATOR . $_FILES['defaultpic']['name']);
                 //保存到db中的相对路径
                 $savePath = $dir . DIRECTORY_SEPARATOR . $_SERVER['REQUEST_TIME'] . '-' . $_FILES['defaultpic']['name'];
             }
         }
         if ($continue) {
             //标题
             $title = $this->getRequest()->getPost('title', '');
             //内容
             $content = $this->getRequest()->getPost('content', '');
             //描述
             $descripion = $this->getRequest()->getPost('descripion', '') ? $this->getRequest()->getPost('descripion', '0') : trim(misc::remove_nbsp(mb_substr(strip_tags($content), 0, 78, 'UTF-8')));
             //关键字(如果没写关键字,在标题中取。如果没取到,标题作为关键词)
             $keywords = empty($this->getRequest()->getPost('keywords', '')) ? implode('   ', misc::getKeywords($title)) : $this->getRequest()->getPost('keywords', '');
             $keywords = empty($keywords) ? $title : $keywords;
             $ret = $this->db_document->addNews(['title' => $title, 'catid' => $this->getRequest()->getPost('catid', 0), 'keywords' => $keywords, 'listorder' => intval($this->getRequest()->getPost('listorder')), 'attribute' => intval($this->getRequest()->getPost('attribute')), 'url' => filter_var($this->getRequest()->getPost('url'), FILTER_VALIDATE_URL) ? $this->getRequest()->getPost('url') : '', 'description' => $descripion, 'inputtime' => $_SERVER['REQUEST_TIME'], 'status' => 99, 'content' => addslashes(stripslashes($content)), 'defaultpic' => $savePath, 'en_keywords' => misc::getEnKeywords($keywords)]);
             if ($ret) {
                 Alert::success('添加成功!');
                 $this->redirect('/admin/document/index');
             } else {
                 Alert::danger('添加失败!');
                 $this->redirect('/admin/document/create');
             }
         } else {
             Alert::danger('缩略图上传失败');
             $this->redirect('/admin/document/create');
         }
         exit;
     }
     $this->getView()->assign('data', $data);
 }
开发者ID:290329416,项目名称:guahao,代码行数:51,代码来源:Document.php

示例2: createAction

 /**
  * 新建页面
  * @author zhangteng
  */
 public function createAction()
 {
     //栏目
     $data['category'] = $this->category->categoryList(['parentid' => 7], 0, 50);
     //判断是否有值提交
     if ($this->getRequest()->isPost()) {
         //内容插入数据库
         $ret = $this->page->insert('page', ['title' => $this->getRequest()->getPost('title', ''), 'catid' => $this->getRequest()->getPost('catid', 0), 'keywords' => $this->getRequest()->getPost('keywords', ''), 'listorder' => intval($this->getRequest()->getPost('listorder')), 'url' => filter_var($this->getRequest()->getPost('url'), FILTER_VALIDATE_URL) ? $this->getRequest()->getPost('url') : '', 'description' => $this->getRequest()->getPost('descripion', '') ? $this->getRequest()->getPost('descripion', '0') : trim(misc::remove_nbsp(mb_substr(strip_tags($content), 0, 78, 'UTF-8'))), 'inputtime' => $_SERVER['REQUEST_TIME'], 'status' => 99, 'content' => addslashes(stripslashes($this->getRequest()->getPost('content', '')))]);
         if ($ret) {
             Alert::success('添加成功!');
             $this->redirect('/admin/page/index');
         } else {
             $referer = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '/admin/page/index';
             $this->redirect($referer);
         }
     }
     $this->getView()->assign('data', $data);
 }
开发者ID:290329416,项目名称:guahao,代码行数:22,代码来源:Page.php

示例3: stringFormat

 /**
  * 字符串格式化
  * @param string $string 要处理的字符串
  * @param int   $start 字符串开始截取的位置
  * @param int   $end 字符截取结束位置
  * @return string 
  */
 public static function stringFormat($string, $start = 0, $end = 10)
 {
     $string = strip_tags($string);
     $string = misc::remove_nbsp($string);
     return mb_substr($string, $start, $end);
 }
开发者ID:290329416,项目名称:guahao,代码行数:13,代码来源:misc.php


注:本文中的misc::remove_nbsp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。