本文整理匯總了PHP中Func::escape方法的典型用法代碼示例。如果您正苦於以下問題:PHP Func::escape方法的具體用法?PHP Func::escape怎麽用?PHP Func::escape使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Func
的用法示例。
在下文中一共展示了Func::escape方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addAction
/**
* 回答接口
*/
public function addAction()
{
//取值,參數驗證,簽名驗證
$vars = ['mem_id', 'mem_mark', 'empty_ans_id', 'mem_relation_id', 'que_id', 'ans_content', 'is_img', 'sign'];
$this->beforeGetVarExecVerify($vars, 'post');
//判斷是否是圖片
if ($this->data['is_img'] == 1) {
$this->data['ans_content'] = \Func::touchImg($this->data['ans_content'], 'ans');
if (!$this->data['ans_content']) {
$this->throwMessage(ILLEGAL_IMAGE);
}
}
//默認執行回答提問方法
$func = 'addAnswer';
//需要的字段
$field = ['mem_id', 'mem_mark', 'mem_relation_id', 'que_id', 'ans_content'];
//根據可空回答id,empty_ans_id判斷是否執行追問方法
if ($this->data['empty_ans_id']) {
array_push($field, $this->data['empty_ans_id']);
$func = 'addAnswerAsk';
}
//轉義回答內容
$this->data['ans_content'] = mb_substr(\Func::escape($this->data['ans_content']), 0, 250, 'utf-8');
//獲取執行狀態,執行失敗,並且是圖片信息,則刪除上傳的圖片
$add_status = $this->callModelFunc('Answer', $func, $field);
if ($add_status != OK && $this->data['is_img'] == 1) {
\FileUtil::getInstance()->unlink(PUBLIC_PATH . $this->data['ans_content']);
}
$this->throwMessage($add_status);
}
示例2: addAction
/**
* 新增提問
*/
public function addAction()
{
//取值,參數驗證,簽名驗證
$vars = ['mem_id', 'mem_mark', 'que_content', 'que_img', 'que_reward', 'tag_ides', 'sign'];
$this->beforeGetVarExecVerify($vars, 'post');
//圖片操作
$this->data['que_img'] = json_decode($this->data['que_img'], true);
$this->data['que_img'] = is_array($this->data['que_img']) ? $this->data['que_img'] : [];
$images = [];
if (!empty($this->data['que_img'])) {
$i = 1;
foreach ($this->data['que_img'] as $key => $val) {
//數組格式不合法
if (!isset($val['img'])) {
\FileUtil::getInstance()->unlink($images, PUBLIC_PATH);
$this->throwMessage(ILLEGAL_ARRAY);
}
//非法的圖片
if (!($images[] = \Func::touchImg($val['img'], 'que'))) {
\FileUtil::getInstance()->unlink($images, PUBLIC_PATH);
$this->throwMessage(ILLEGAL_IMAGE);
}
//控製提問最多可上傳的數量
$i++;
if ($i > QUESTION_MAX_IMAGE) {
break;
}
}
}
//處理字段
$this->data['que_img'] = $images;
$this->data['que_content'] = \Func::escape($this->data['que_content']);
//所需字段
$field = ["mem_id", "mem_mark", "que_content", "que_img", "que_reward", "tag_ides"];
$add_status = $this->callModelFunc('Question', 'addQuestion', $field);
if ($add_status != OK) {
\FileUtil::getInstance()->unlink($images, PUBLIC_PATH);
}
$this->throwMessage($add_status);
}
示例3: setNicknameAction
/**
* 修改昵稱
*/
public function setNicknameAction()
{
$vars = ['mem_id', 'mem_mark', 'mem_nickname', 'sign'];
$this->beforeGetVarExecVerify($vars);
//轉義昵稱
$this->data['mem_nickname'] = \Func::escape($this->data['mem_nickname']);
//修改昵稱
$field = ['mem_id', 'mem_mark', 'mem_nickname'];
$upd_status = $this->callModelFunc('Member', 'updMemNickname', $field);
$this->throwMessage($upd_status);
}