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


PHP str::strLen方法代码示例

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


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

示例1: long_text

 /**
  * 获取长文本广播
  */
 public function long_text()
 {
     if (request::method() != 'get') {
         $this->send_response(400, NULL, '400:无法接受GET以外请求方式');
     }
     $statuses_id = $this->input->get('statuses_id', '');
     $pagesize = $this->input->get('pagesize', 0);
     $page = $this->input->get('page', 1);
     $pagepad = $page > 1 ? ($page - 1) * $pagesize : 0;
     if ($statuses_id) {
         $feed = $this->feedModel->findFeed($statuses_id);
         $str_count = str::strLen($feed['long_text']);
         if ($pagesize && $str_count > $pagesize) {
             $tmp_text = str::cnSubstr($feed['long_text'], $pagepad, $pagesize);
         } else {
             $tmp_text = $feed['long_text'];
         }
     }
     $data = array('id' => $statuses_id, 'pagesize' => $pagesize, 'page' => $page, 'total' => $str_count, 'text' => $tmp_text, 'at' => $feed['at']);
     $this->send_response(200, $data);
 }
开发者ID:momoim,项目名称:momo-api,代码行数:24,代码来源:statuses.php

示例2: _sync_weibo

 /**
  * 
  * @param $uid
  * @param $site
  * @param $content
  * @param $image
  * @return unknown_type
  */
 private function _sync_weibo($sync, $uid, $site, $title, $description, $image, $location)
 {
     $res = array();
     if (is_array($sync) && count($sync) > 0 && $title && $description && $image) {
         if ($sync['weibo']) {
             require_once Kohana::find_file('vendor', 'weibo/saetv2.ex.class');
             $oauth = Kohana::config('uap.oauth');
             $token = Bind_Model::instance()->oauth2_check($uid, 'weibo');
             $updated_time = $token['updated'] ? $token['updated'] : $token['created'];
             if ($updated_time + $token['expires_in'] > time()) {
                 $c = new SaeTClientV2($oauth['weibo.com']['WB_AKEY'], $oauth['weibo.com']['WB_SKEY'], $token['access_token']);
                 if ($c) {
                     $img = $this->model->_warp_image($image);
                     $img_url = $img[0]['url'] ? $img[0]['url'] : '';
                     $content = '#' . $title . '#' . $description;
                     $content = str::strLen($content) > 120 ? str::cnSubstr($content, 0, 120) . '..' : $content;
                     //$img_url = 'http://momoimg.com/photo/3846870_LrurOnCRM365Gc_cI0ferPZaqFP2hLDtdsB2R1WtHFsrGiLDQ647LfN09AM_780.jpg';
                     $latitude = $location['latitude'] ? $location['latitude'] : NULL;
                     $longitude = $location['longitude'] ? $location['longitude'] : NULL;
                     if ($img_url) {
                         $result = $c->upload($content, $img_url, $latitude, $longitude);
                     } else {
                         $result = $c->update($content, $latitude, $longitude);
                     }
                     if ($result['id']) {
                         $res = array('weibo' => 1);
                     } else {
                         $res = array('weibo' => 0, 'error' => $result['error'], 'type' => 'error');
                     }
                 }
             } else {
                 $res = array('weibo' => 0, 'error' => 'access_token expired!', 'type' => 'expire');
             }
         }
     }
     return $res;
 }
开发者ID:momoim,项目名称:momo-api,代码行数:45,代码来源:deal.php

示例3: create

 /**
  * 创建活动
  */
 public function create()
 {
     if ($this->get_method() != 'POST') {
         $this->send_response(405, NULL, '请求的方法不存在');
     }
     $data = $this->get_data();
     if (!$data) {
         $this->send_response(400, NULL, '400505:活动信息非法');
     }
     $post = new Validation($data);
     $post->add_rules('title', 'required', 'length[1, 30]');
     $post->add_rules('content', 'required', 'length[0, 10000]');
     $post->add_rules('start_time', 'required');
     //$post->add_rules('end_time', 'required');
     //$post->add_rules('assemble_location', 'required');
     $post->add_rules('event_location', 'required');
     $post->add_rules('type', 'required', 'numeric', array($this, '_check_type_validation'));
     $post->add_callbacks(TRUE, array($this, '_check_time_validation'));
     if ($post->validate()) {
         $form = $post->as_array();
         $event = array();
         $event['organizer'] = $this->user_id;
         $event['type'] = $form['type'];
         $event['title'] = $form['title'];
         $event['summary'] = empty($form['summary']) ? '' : $form['summary'];
         $event['deadline'] = empty($form['deadline']) ? 0 : $form['deadline'];
         $event['apply_desc'] = empty($form['apply_desc']) ? '' : $form['apply_desc'];
         $event['content'] = $form['content'];
         $event['start_time'] = $form['start_time'];
         if ($form['end_time']) {
             $event['end_time'] = $form['end_time'];
         }
         $event['city'] = $form['city'] ? $form['city'] : 3501;
         $event['private'] = (int) $form['private'];
         $event['fee'] = $form['fee'] ? $form['fee'] : '';
         if ($form['apply_doc']) {
             if (!$this->_check_apply_doc($form['apply_doc'])) {
                 $this->send_response(400, NULL, '400413:apply_doc信息非法');
             }
             $event['apply_doc'] = serialize($form['apply_doc']);
         }
         $event['status'] = 1;
         $event['create_time'] = time();
         $event['event_location'] = serialize($form['event_location']);
         if ($form['assemble_location']) {
             $event['assemble_location'] = serialize($form['assemble_location']);
         }
         $event_id = $this->model->add($event);
         if ($event_id) {
             if ($form['image']) {
                 $this->_create_event_image($event_id, $form['image']);
             }
             if ($form['apply_doc']) {
                 $this->_create_event_apply_doc($event_id, $form['apply_doc']);
             }
             //创建群组
             $group_id = $this->_create_group($event);
             if ($group_id) {
                 $this->_add_group_user($group_id, $this->user_id, Kohana::config('group.grade.master'));
                 $this->model->update($event_id, array('gid' => $group_id));
             }
             $user = sns::getuser($this->user_id);
             $eventUser = array('eid' => $event_id, 'pid' => 0, 'uid' => $this->user_id, 'name' => $user['realname'], 'mobile' => $user['mobile'], 'apply_type' => Kohana::config('event.apply_type.joined'), 'apply_time' => time(), 'grade' => Kohana::config('event.grade.creator'));
             $this->model->applyEvent($eventUser);
             $opt = array('event' => array('id' => $event_id, 'name' => $event['title'], 'cover' => ''), 'no_sign' => 1);
             $event_url = MO_EVENT . 'event/show/' . $event_id;
             $short_title = str::strLen($event['title']) > 10 ? str::cnSubstr($event['title'], 0, 10) . '..' : $event['title'];
             $event_short_url = url::getShortUrl($event_url);
             $content = '【' . $event_short_url . ' 】由' . $user['realname'] . '发起的活动,快来参加吧';
             $this->send_event_mq(Kohana::config('uap.xiaomo'), $this->user_id, $content, $opt);
             $this->send_response(200, array('id' => floatval($event_id), 'gid' => (int) $group_id));
         }
         $this->send_response(400, NULL, '400413:活动发布失败');
     }
     $errors = $post->errors();
     foreach ($errors as $key => $value) {
         switch ($key) {
             case 'type':
                 $this->send_response(400, NULL, '400405:活动类型为空');
                 break;
             case 'start_time':
                 $this->send_response(400, NULL, '400406:活动开始时间为空');
                 break;
             case 'end_time':
                 $this->send_response(400, NULL, '400407:活动结束时间为空');
                 break;
             case 'assemble_location':
                 $this->send_response(400, NULL, '400408:集合地点为空');
                 break;
             case 'event_location':
                 $this->send_response(400, NULL, '400409:活动地点为空');
                 break;
             case 'end_before_start':
                 $this->send_response(400, NULL, '400410:活动结束时间必须大于开始时间');
                 break;
             case 'content':
                 $this->send_response(400, NULL, '400411:活动内容为空');
//.........这里部分代码省略.........
开发者ID:momoim,项目名称:momo-api,代码行数:101,代码来源:event.php


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