IBOS open source
  • Namespace
  • Class

Namespaces

  • application
    • core
      • cache
        • driver
        • provider
      • components
      • controllers
      • engines
        • local
        • sae
      • model
      • modules
      • utils
      • widgets
    • modules
      • article
        • controllers
        • core
        • model
        • utils
      • calendar
        • controllers
        • model
        • utils
      • contact
        • controllers
        • model
        • utils
      • dashboard
        • controllers
        • model
        • utils
      • department
        • components
        • model
        • utils
      • diary
        • components
        • controllers
        • model
        • utils
        • widgets
      • email
        • controllers
        • core
        • model
        • utils
      • main
        • behaviors
        • components
        • controllers
        • model
        • utils
        • widgets
      • message
        • controllers
        • core
          • co
          • wx
            • callback
            • event
        • model
        • utils
      • mobile
        • components
        • controllers
        • utils
      • position
        • components
        • model
        • utils
      • recruit
        • components
        • controllers
        • core
        • model
        • utils
        • widgets
      • role
        • model
        • utils
      • user
        • components
        • controllers
        • model
        • utils
      • vote
        • components
        • controllers
        • model
        • utils
      • weibo
        • controllers
        • core
        • model
        • utils

Classes

  • Api
  • ApiCode
  • Attach
  • Cache
  • Cloud
  • Convert
  • Credit
  • Database
  • DateTime
  • Env
  • File
  • Ftp
  • IBOS
  • Image
  • Mail
  • Module
  • Org
  • Page
  • PHPExcel
  • String
  • System
  • Upgrade
  • Url
  • WebSite
  • Xml
  • XMLParse

Class String

Namespace: application\core\utils
Copyright: Copyright © 2012-2013 IBOS Inc
Author: banyanCheung banyan@ibos.com.cn
Located at system/core/utils/String.php

Methods summary

public static boolean
# isEmail( string $email )

检测一个字符串是否email格式

检测一个字符串是否email格式

Parameters

$email

Returns

boolean
public static boolean
# isMobile( string $str )

检测一个字符串是否手机格式

检测一个字符串是否手机格式

Parameters

$str

Returns

boolean
public static boolean
# istrpos( string $string, array $arr, boolean $returnValue = false )

字符串方式实现 preg_match("/(s1|s2|s3)/", $string, $match)

字符串方式实现 preg_match("/(s1|s2|s3)/", $string, $match)

Parameters

$string
源字符串
$arr
要查找的字符串 如array('s1', 's2', 's3')
$returnValue
是否返回找到的值

Returns

boolean
public static mixed
# iaddSlashes( string $string, integer $force = 1 )

对字符串或者输入进行 addslashes 操作

对字符串或者输入进行 addslashes 操作

Parameters

$string
$force

Returns

mixed
public static string
# authCode( string $string, string $operation = 'DECODE', string $key = '', integer $expiry = 0 )

对字符串进行加密和解密

对字符串进行加密和解密

Parameters

$string
$operation
DECODE 解密 | ENCODE 加密
$key
当为空的时候,取全局密钥
$expiry
有效期,单位秒

Returns

string

Author

Ring
public static string
# random( integer $length, integer $numeric = 0 )

产生随机码

产生随机码

Parameters

$length
要多长
$numeric
$numberic 数字还是字符串

Returns

string
$hash 返回字符串
public static string
# ihtmlSpecialChars( mixed $string, mixed $flags = null )

HTML转义字符

HTML转义字符

Parameters

$string
数组或字符串
$flags
htmlspecialchars函数的标记

Returns

string
返回转义好的字符串

Link

http://www.php.net/manual/zh/function.htmlspecialchars.php
public static string
# cutStr( string $string, integer $length, string $dot = ' ...' )

根据中文裁减字符串

根据中文裁减字符串

Parameters

$string
  • 字符串
$length
  • 长度
$dot
$doc - 缩略后缀 default=' ...'

Returns

string
返回带省略号被裁减好的字符串
public static integer
# iStrLen( string $str )

针对uft-8进行特殊处理的strlen函数 (原名dstrlen)

针对uft-8进行特殊处理的strlen函数 (原名dstrlen)

Parameters

$str

Returns

integer
字符串的长度

Author

Ring
public static boolean
# findIn( string $string, string $id )

查找是否包含在内,两边都可以是英文逗号相连的字符串 原名(findin)

查找是否包含在内,两边都可以是英文逗号相连的字符串 原名(findin)

Parameters

$string
目标范围
$id
所有值

Returns

boolean

Author

Ring
public static boolean
# isIp( string $ip )

判断给定的参数是否是一个有效的IP地址 原名(isip)

判断给定的参数是否是一个有效的IP地址 原名(isip)

Parameters

$ip
ip地址字符串

Returns

boolean

Author

Ring
public static boolean
# strExists( string $string, string $find )

判断一个字符串是否在另一个字符串中存在

判断一个字符串是否在另一个字符串中存在

Parameters

$string
$string
$find
$find

Returns

boolean
public static string
# getSubIp( string $ip = '' )

返回一个形如10.0..这样的IP 原名(get_sub_ip)

返回一个形如10.0..这样的IP 原名(get_sub_ip)

Parameters

$ip
ip地址字符串

Returns

string

Author

Ring
public static string
# displayIp( string $str )

返回显示IP的字符串 原名(ip_show)

返回显示IP的字符串 原名(ip_show)

Parameters

$str

Returns

string

Author

Ring
public static string
# iImplode( array $array )

特别处理数组连接成字符串 带单引号 原名(dimplode)

特别处理数组连接成字符串 带单引号 原名(dimplode)

Parameters

$array

Returns

string

Author

Ring
public static array
# splitParam( string $param )

分割参数字符串返回数组。方便url组件创建URL

$param = 'a=3&b=4';
        $splitParam = String::splitParam($param);

分割参数字符串返回数组。方便url组件创建URL

$param = 'a=3&b=4';
        $splitParam = String::splitParam($param);

Parameters

$param

Returns

array
public static array
# splitSql( string $sql )

处理sql语句

处理sql语句

Parameters

$sql
原始的sql

Returns

array
public static string
# passwordMask( string $password )

把密码字符串转换为可显示的形式

$password = '19881014';
echo String::passwordMask($password);
// returns '1********14';

把密码字符串转换为可显示的形式

$password = '19881014';
echo String::passwordMask($password);
// returns '1********14';

Parameters

$password

Returns

string
public static mixed
# clearLogString( mixed $str )

过滤日志字符串

过滤日志字符串

Parameters

$str

Returns

mixed
public static string
# getTree( array $data, string $format = "<option value='\$catid' \$selected>\$spacer\$name</option>", integer $id = 0, string $nbsp = '&nbsp;&nbsp;&nbsp;&nbsp;', array $icon = array( '&nbsp;&nbsp;', '&nbsp;&nbsp;', '&nbsp;&nbsp;' ) )

封装Tree类,快速获取有层级的分类树

$format = "<option value='\$catid' \$selected>\$spacer\$name</option>";
 $data = Ibos:app()->setting->get('cache/positioncategory');
 $trees = String::getTree($data,$format);

封装Tree类,快速获取有层级的分类树

$format = "<option value='\$catid' \$selected>\$spacer\$name</option>";
 $data = Ibos:app()->setting->get('cache/positioncategory');
 $trees = String::getTree($data,$format);

Parameters

$data
树数据
$format
生成的格式字符串
$id
被选中的ID,比如在做树型下拉框的时候需要用到
$nbsp
间隔,取决于$spacer放在格式字符串的那里
$icon
修饰符号,可以换成图片

Returns

string
public static array
# getId( mixed $ids, boolean $index = false )

获取分与不分前缀的id

获取分与不分前缀的id

Parameters

$ids
$index
按前缀索引

Returns

array
public static array
# getUid( mixed $ids )

获取有前缀的id字符串所包含的uid数组

获取有前缀的id字符串所包含的uid数组

Parameters

$ids

Returns

array
public static string
# wrapId( array $ids, string $identifier = 'u', string $glue = ',' )

封装id加上前缀

$id = array(23,24,25,26);
print_r(String::wrapId($id));
return 'u_23,u_24,u_25,u_26';

封装id加上前缀

$id = array(23,24,25,26);
print_r(String::wrapId($id));
return 'u_23,u_24,u_25,u_26';

Parameters

$ids
id数组\
$identifier
前缀
$glue
分隔符

Returns

string
public static array
# getUidByIdentifier( string $identifier, string $str )

根据id标识符查找所包含的uid

根据id标识符查找所包含的uid

Parameters

$identifier
标识符,eg:u,d,p
$str
完整id字符串

Returns

array
返回uid组成的数组
public static integer
# iIntval( integer $int, boolean $allowArray = false )

封装Intval函数,加上数组支持

封装Intval函数,加上数组支持

Parameters

$int
$allowArray

Returns

integer
public static
# getFileExt( $fileName )

获取文件扩展名

获取文件扩展名

Parameters

$fileName
文件名

Since

IBOS1.0
public static
# pregHtml( $html )

正则替换和过滤内容

Parameters

$html

Author

jason
public static integer
# getStrLength( string $str, boolean $filter = false )

获取字符串的长度

获取字符串的长度

计算时, 汉字或全角字符占1个长度, 英文字符占0.5个长度

Parameters

$str
$filter
是否过滤html标签

Returns

integer
字符串的长度
public static string
# filterCleanHtml( string $text )

用于过滤标签,输出没有html的干净的文本

用于过滤标签,输出没有html的干净的文本

Parameters

$text
文本内容

Returns

string
处理后内容
public static type
# realStripTags( type $str, type $allowableTags = "" )

Parameters

$str
$allowableTags

Returns

type
public static string
# filterDangerTag( string $text, string $type = 'html' )

用于过滤不安全的html标签,输出安全的html

用于过滤不安全的html标签,输出安全的html

Parameters

$text
待过滤的字符串
$type
保留的标签格式

Returns

string
处理后内容
public static string
# filterStr( string $string, string $delimiter = ',', boolean $unique = true )

过滤字符串

过滤字符串

Parameters

$string
要过滤的字符串
$delimiter
分割符
$unique
是否过滤重复值

Returns

string
过滤后的字符串
public static type
# parseForApi( type $html )

解析成api显示格式

解析成api显示格式

Parameters

$html

Returns

type
public static type
# parseWapAtByUname( type $name )

Parameters

$name

Returns

type
public static string
# replaceExpression( string $html )

表情替换(用于页面显示)

表情替换(用于页面显示)

Parameters

$html

Returns

string
public static type
# parseHtml( type $html )

解析数据成网页端显示格式

解析数据成网页端显示格式

Parameters

$html

Returns

type
public static
# parseUrl( string $url )

格式化微博,替换链接地址

格式化微博,替换链接地址

Parameters

$url
public static string
# formatFeedContentUrlLength( string $match )

格式化微博内容中url内容的长度

格式化微博内容中url内容的长度

Parameters

$match
匹配后的字符串

Returns

string
格式化后的字符串
public static
# replaceUrl( $content )
public static string
# createGuid( )

生成GUID(用户唯一ID)

生成GUID(用户唯一ID)

Returns

string
public static type
# joinSelectBoxValue( string $deptid, string $positionid, string $uid )

组合选人框的值

组合选人框的值

Parameters

$deptid
部门id
$positionid
岗位Id
$uid
用户id

Returns

type
IBOS open source API documentation generated by ApiGen