本文整理汇总了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);
}
示例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);
}
示例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);
}