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