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


PHP string类代码示例

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


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

示例1: lookupUser

 function lookupUser($user)
 {
     $script = 'knowledgeBaseCGI.pl';
     $action = 'lookup';
     debug::message($user);
     $user = string::low($user);
     $groupPredicates[0] = new prologString($user);
     $constructList = new prologConstructCollection();
     //Add predicate to construct collection
     $constructList->addConstruct(new prologPredicate('get_post_value', $groupPredicates));
     $userList = $constructList->toArray();
     $filename = prolog::transferToProlog($user, $userList);
     return prolog::exec($script, $action, $filename);
 }
开发者ID:printedheart,项目名称:iwfms,代码行数:14,代码来源:prolog.php

示例2: parse

 /**
  * @brief Parse the human data and return html
  *
  * @param string $data The data to parse
  * @return string The parsed data
  */
 public function parse($content)
 {
     $str = $content;
     $str = string::rereplace($str, '/</', '&lt;');
     $str = string::rereplace($str, '/>/', '&gt;');
     $str = string::rereplace($str, '/\\\\"/', '&quot;');
     // First chunk everything into paragraphs...
     $str = string::rereplace($str, '/(.+)/', '<p>\\1</p>');
     // Then take care of multiple newlines
     $str = string::rereplace($str, '/(\\r|\\n){2}/', '<br>');
     // The usual, bold, italics, etc...
     $str = string::rereplace($str, '/\\/(.*?)\\//', '<em>\\1</em>');
     $str = string::rereplace($str, '/\\*(.*?)\\*/', '<strong>\\1</strong>');
     $str = string::rereplace($str, '/_(.*?)_/', '<u>\\1</u>');
     $tag_re = '/\\#([a-zA-Z0-9]+)/s';
     $group_re = '/\\!([a-zA-Z0-9]+)/s';
     /*
     preg_match_all($tag_re, $content, $tags);
     preg_match_all($group_re, $content, $groups);
     
     $this->setMeta(MarkupParser::META_TAGS, $tags[1]);
     $this->setMeta(MarkupParser::META_GROUPS, $groups[1]);
     */
     $str = string::rereplace($str, $tag_re, '<a href="/tags/\\1">#\\1</a>');
     $str = string::rereplace($str, $group_re, '<a href="/groups/\\1">!\\1</a>');
     $str = string::rereplace($str, '/\\@([a-zA-Z0-9]+)/s', '<a href="/user/\\1">@\\1</a>');
     // A bit of a hack...but it works... let me know if you have a regex that fixes this :p
     $str = string::rereplace($str, '/<strong><\\/strong>/', '**');
     $str = string::rereplace($str, '/<em><\\/em>/', '//');
     $str = string::rereplace($str, '/<u><\\/u>/', '__');
     $str = string::rereplace($str, '/(https?:\\/\\/\\S+)/', '<a href="\\1" rel="nofollow">\\1</a>');
     return $str;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:39,代码来源:human.php

示例3: doadd

 /**
 添加、编辑参考资料
 编辑操作被整合到了add当中,由$_ENV['reference']->add()实现,
 如果 $data 当中包含 id 信息则执行edit操作,否则执行add操作。
 */
 function doadd()
 {
     if ($this->get[2] == 'checkable') {
         if ($this->checkable('reference-add')) {
             if ($this->setting['doc_verification_reference_code']) {
                 exit('CODE');
             } else {
                 exit('OK');
             }
         } else {
             exit('0');
         }
     }
     $data = $this->post['data'];
     //检查验证码
     if ($this->setting['checkcode'] != 3 && $this->setting['doc_verification_reference_code'] && strtolower($data['code']) != $_ENV['user']->get_code()) {
         exit('code.error');
     }
     if (WIKI_CHARSET == 'GBK') {
         $data['name'] = string::hiconv($data['name']);
     }
     if (empty($data['name'])) {
         exit('0');
     }
     $insert_id = $_ENV['reference']->add($data);
     if (is_int($insert_id)) {
         echo $insert_id;
     } else {
         echo $insert_id ? '1' : '0';
     }
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:36,代码来源:reference.php

示例4: doedit

 function doedit()
 {
     if (!isset($this->post['editsubmit'])) {
         $did = isset($this->get[2]) ? $this->get[2] : '';
         if (!is_numeric($did)) {
             $this->message($this->view->lang['docIdMustNum'], 'BACK');
         }
         $focus = $this->db->fetch_by_field('focus', 'did', $did);
         $focus['time'] = $this->date($focus['time']);
         $this->view->assign("focus", $focus);
         $this->view->display("admin_focus_content");
     } else {
         $did = isset($this->post['did']) ? $this->post['did'] : '';
         if (!is_numeric($did)) {
             $this->message($this->view->lang['docIdMustNum'], 'BACK');
         }
         $summary = string::hiconv($this->post['summary']);
         $image = string::hiconv($this->post['image']);
         $order = $this->post['displayorder'];
         $type = $this->post['doctype'];
         if (is_numeric($order) && $_ENV['doc']->save_focus_content($did, $summary, $image, $order, $type)) {
             $this->cache->removecache('data_' . $GLOBALS['theme'] . '_index');
             $this->message($this->view->lang['docEditSuccess'], "index.php?admin_focus-edit-{$did}");
         } else {
             $this->message($this->view->lang['docEditFail'], 'BACK');
         }
     }
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:28,代码来源:admin_focus.php

示例5: existsMacAddr

 function existsMacAddr($mac_addr, $app_id = "")
 {
     $mac_addr = $this->getFlatMacAddr($mac_addr);
     $args = array();
     $args[0] = $mac_addr;
     $args['COND'] = "";
     if ($app_id != "") {
         $args['COND'] = " AND app_id != " . string::replaceSql($app_id);
     }
     // 実データでチェック
     $args['TYPE'] = "tbl";
     $sql = $this->getQuery('EXISTS_MAC_ADDR', $args);
     $id = $this->oDb->getOne($sql);
     if ($id != "") {
         return true;
     }
     // 申請データでチェック
     $args['TYPE'] = "entry";
     $args['COND'] = " AND entry_status = '0'";
     $sql = $this->getQuery('EXISTS_MAC_ADDR', $args);
     $id = $this->oDb->getOne($sql);
     if ($id != "") {
         return true;
     }
     return false;
 }
开发者ID:honda-kyoto,项目名称:UMS-Kyoto,代码行数:26,代码来源:apps_regist_common_mgr.class.php

示例6: __autoload

function __autoload($class_name)
{
    if (strstr($class_name, 'app')) {
        $class_name = string::strtolower(str_replace('app', '', $class_name));
        $file = APPS . $class_name . '/' . $class_name . ".app.php";
        if (file_exists($file)) {
            require_once $file;
        } else {
            exit("Class <b>{$class_name}</b> not found<br />");
        }
        return true;
    }
    $file1 = SYS_ROOT . "libs/" . $class_name . ".php";
    $file2 = SYS_ROOT . "core/" . $class_name . ".php";
    $file3 = SYS_ROOT . "boot/" . $class_name . ".php";
    if (file_exists($file1)) {
        require_once $file1;
    } else {
        if (file_exists($file2)) {
            require_once $file2;
        } else {
            if (file_exists($file3)) {
                require_once $file3;
            } else {
                exit("Class <b>{$class_name}</b> not found<br />");
            }
        }
    }
}
开发者ID:rigidus,项目名称:ea,代码行数:29,代码来源:global.php

示例7: douniontitle

 function douniontitle()
 {
     @header('Content-type: application/json; charset=' . WIKI_CHARSET);
     $len = strlen('plugin-hdapi-hdapi-uniontitle-');
     $did = substr($_SERVER['QUERY_STRING'], $len);
     $doc = $_ENV["hdapi"]->get_doc_title_by_id($did, 'title');
     if (!isset($doc['title'])) {
         exit;
     }
     $is_private_title = $_ENV['hdapi']->is_private_title($doc['title']);
     if (!empty($is_private_title)) {
         exit;
     }
     $uniontitle = $_ENV["hdapi"]->get_uniontitle_by_did($did);
     if (empty($uniontitle)) {
         $uniontitle = $_ENV["hdapi"]->get_tit_url($doc['title']);
         if (isset($uniontitle['docdeclaration']) && strtolower(WIKI_CHARSET) == 'gbk') {
             $uniontitle['docdeclaration'] = string::hiconv($uniontitle['docdeclaration'], 'gbk', 'utf-8');
         }
         if (!empty($uniontitle['docdeclaration'])) {
             $_ENV["hdapi"]->save_uniontitle_by_did($did, $uniontitle['docdeclaration']);
         }
     }
     if (is_array($uniontitle) && isset($uniontitle['docdeclaration'])) {
         $uniontitle = $uniontitle['docdeclaration'];
     } else {
         $uniontitle = '';
     }
     echo $uniontitle;
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:30,代码来源:hdapi.php

示例8: init

 public static function init()
 {
     $username = get('username');
     $password = get('password');
     if (!$username) {
         exit('Пожалуйста, укажите имя для пользователя.');
     }
     if (!$password) {
         exit('Пожалуйста, укажите пароль пользователю.');
     }
     if (string::length($password) < 6) {
         exit('Ваш пароль не может быть менее 6 символов.');
     }
     $user = users::get_by_name($username);
     if (!$user) {
         exit('Данного пользователя не существует.');
     }
     if (!crypt::is_valid($password, $user->hash, $user->salt)) {
         exit('Указанный вами пароль не совпадает с тем, что был указан при регистрации.');
     }
     $is_authorized = template_session::login($user->id);
     if (!$is_authorized) {
         exit('Нарушение логической цепи: авторизация не произведена.');
     }
 }
开发者ID:ThisNameWasFree,项目名称:rude-univ,代码行数:25,代码来源:rude-ajax-authorization.php

示例9: doupdateorder

 function doupdateorder()
 {
     $channel_num = string::stripspecialcharacter(trim($this->post['order']));
     $order = explode(",", $channel_num);
     $_ENV['channel']->updateorder($order);
     $this->cache->removecache('channel');
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:7,代码来源:admin_channel.php

示例10: highlight

 function highlight($query, $content)
 {
     $point_dl = 100;
     $query = string::utf2win($query);
     $content = string::utf2win($content);
     $content = strip_tags($content);
     $content_st = $content_and = '';
     $point = stripos($content, $query);
     $point1 = $point - $point_dl;
     if ($point1 < 0) {
         $point1 = 0;
     } else {
         $content_st = '...';
     }
     $len = strlen($content);
     $point2 = $point + $point_dl;
     if ($point2 < $len) {
         $content_end = '...';
     } else {
         $content_end = '';
     }
     $content = $content_st . substr($content, $point1, $point2) . $content_end;
     $content = str_ireplace($query, '<span style="background-color: yellow; color: black;">' . $query . '</span>', $content);
     $query = string::win2utf($query);
     $content = string::highlight(string::win2utf($content), $query);
     return $content;
 }
开发者ID:rigidus,项目名称:ea,代码行数:27,代码来源:search.php

示例11: dolist

 function dolist()
 {
     $page = !empty($this->get[2]) && is_numeric($this->get[2]) ? $this->get[2] : 1;
     $num = !empty($this->get[3]) && is_numeric($this->get[3]) ? $this->get[3] : 50;
     if ($page < 1) {
         $page = 1;
     }
     $doclist = array();
     $count = $_ENV['archiver']->get_total_num();
     if (0 < $count) {
         // 获得词条最大ID
         $maxdid = $_ENV['archiver']->get_max_did();
         $doclist = $_ENV['archiver']->get_doc_list(array('page' => $page, 'num' => $num));
         // 分页数据
         $totalpage = ceil($count / $num);
         $outhtml = $_ENV['archiver']->get_html_list($doclist, $totalpage, $num, $count, $maxdid);
     } else {
         $outhtml = $_ENV['archiver']->get_html_header() . 'No Body! No Body!' . $_ENV['archiver']->get_html_footer();
     }
     if ('gbk' == strtolower(WIKI_CHARSET)) {
         $outhtml = string::hiconv($outhtml, 'utf-8', 'gbk');
     }
     $_ENV['archiver']->close_mysql();
     echo $outhtml;
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:25,代码来源:archiver.php

示例12: getPage

 /**
  * Return a wiki page
  * @param string $pagename The namespace and page name in the
  *   format of ns:page (ex. wiki:howto)
  * @return WikiPage The page
  */
 function getPage($pagename, $revision = Wiki::REVISION_LATEST)
 {
     list($ns, $uri) = string::parseUri($pagename, 'default');
     $db = new DatabaseConnection();
     try {
         if ($revision == Wiki::REVISION_LATEST) {
             $rs = $db->getSingleRow("SELECT * FROM wiki WHERE ns='%s' AND uri='%s' AND reverted=0 ORDER BY revision DESC LIMIT 1", $ns, $uri);
         } else {
             $rs = $db->getSingleRow("SELECT * FROM wiki WHERE ns='%s' AND uri='%s' AND revision='%d'", $ns, $uri, $revision);
         }
         $author = null;
         if ($rs) {
             $rev = $rs['revision'];
             $title = $rs['title'];
             $content = str_replace('\\"', '"', $rs['content']);
             $author = User::getUser($rs['author']);
             $edited = $rs['lastedit'];
             $locked = false;
         } else {
             $rev = 1;
             $title = 'New page';
             $content = 'This page has not yet been created or revision not found.';
             $edited = null;
             $author = null;
             $locked = false;
         }
     } catch (DBXException $e) {
         $rev = 1;
         $title = 'ERROR';
         $content = 'Error retrieving page.';
         $locked = true;
     }
     $page = new WikiPage(array('ns' => $ns, 'uri' => $uri, 'revision' => $rev, 'lastedit' => $edited, 'author' => $author, 'authorname' => $author->displayname, 'title' => $title, 'content' => $content, 'reverted' => false, 'locked' => $locked, 'hidden' => false));
     return $page;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:41,代码来源:wiki.php

示例13: dodefault

 function dodefault()
 {
     if (!isset($this->post['submit'])) {
         $this->view->assign("relatedoc", $this->setting['relateddoc']);
         $this->view->assign("isrelate", $this->setting['isrelate']);
         $this->view->display("admin_relation");
         exit;
     }
     $isrelate = $this->post['isrelate'];
     $setting = array();
     $relatedoc = trim($this->post['relatedoc']);
     $relatelist = array_unique(explode(';', $relatedoc));
     foreach ($relatelist as $relate) {
         $relate = trim($relate);
         $relate = string::stripscript($relate);
         if (empty($relate)) {
             unset($relate);
         } else {
             $relate = string::haddslashes($relate);
             $relatelists[] = $relate;
         }
     }
     if (count($relatelist) > 10) {
         $this->message($this->view->lang['relatedtitlemore'], 'index.php?admin_relation');
     }
     $setting['relateddoc'] = implode(";", $relatelists);
     $setting['isrelate'] = $isrelate;
     $_ENV['setting']->update_setting($setting);
     $this->cache->removecache('setting');
     $this->message($this->view->lang['relatedtitlesuccess'], 'index.php?admin_relation');
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:31,代码来源:admin_relation.php

示例14: return_relevant

 /**
  * Try to find searched value and return whole sentence
  * @return string sentence without html
  * @param string to search in
  * @param string to be searched
  */
 public function return_relevant($value, $search)
 {
     if (empty($search)) {
         return;
     } else {
         $value = strip_tags($value);
         $word_pos = strpos($value, $search);
         // Find position of searched word
         if ($word_pos === FALSE) {
             // If there is no position, return first sentence
             $next_fullstop = strpos($value, '. ', 0);
             if ($next_fullstop === FALSE) {
                 // If there is no fullstop then truncate to certain length
                 return string::trim_text($value, 100) . '...';
             } else {
                 return substr($value, 0, $next_fullstop) . '...';
             }
         } else {
             $next_fullstop = strpos($value, '. ', $word_pos);
             if ($next_fullstop === FALSE) {
                 // If there is no fullstop then truncate to certain lenght
                 return string::trim_text($value, 100) . '...';
             } else {
                 $prev_fullstop = self::rstrpos($value, '. ', $word_pos);
                 return '...' . substr($value, $prev_fullstop, $next_fullstop - $prev_fullstop) . '...';
             }
         }
     }
 }
开发者ID:repli2dev,项目名称:re-eshop,代码行数:35,代码来源:string.php

示例15: checkInputdata

 function checkInputdata()
 {
     if (!$this->oMgr->checkEmpty($this->request['login_passwd'])) {
         // エラーメッセージをセット
         $this->oMgr->setErr('E001', "新しいパスワード");
     } else {
         if (!$this->oMgr->checkEmpty($this->request['login_passwd_conf'])) {
             // エラーメッセージをセット
             $this->oMgr->setErr('E001', "新しいパスワード(確認用)");
         } else {
             if ($this->request['login_passwd'] != $this->request['login_passwd_conf']) {
                 // エラーメッセージをセット
                 $this->oMgr->setErr('E501');
             } else {
                 $passwd = $this->request['login_passwd'];
                 if (!string::checkAlphanumWide($passwd, 6, 20) || !ereg("[0-9]", $passwd) || !ereg("[a-z]", $passwd) || !ereg("[A-Z]", $passwd)) {
                     $param = array();
                     $param[0] = "パスワード";
                     $param[1] = "数字、英字大文字、英字小文字を各1文字以上使用し、6~20文字";
                     // エラーメッセージをセット
                     $this->oMgr->setErr('E004', $param);
                 }
             }
         }
     }
     // エラーなし
     if (sizeof($this->oMgr->aryErrMsg) == 0) {
         return true;
     }
     // エラー発生
     $this->errMsg = $this->oMgr->getErrMsg();
     return false;
 }
开发者ID:honda-kyoto,项目名称:UMS-Kyoto,代码行数:33,代码来源:init_passwd.class.php


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