php代码
去日租程序是一款具有强大的功能的基于.NET+SQL2000+AJAX构架的房屋出租管理系统。 日租网站管理系统,采用ASP.NET2.0语言开发,它集成租房模块、文章模块、订单模块、邮箱短信模块、用户模板、SEO优化模块、房间模块、支付模块等多项强大功能。系统有多年经验的高级工程师采用三层架构开发,页面代码全部采用DIV+CSS,完全符合SEO标准,有利于搜索引擎关键排名优化。日租网站
0
<?php
class MST_String {
const
DET_HIGHLIGHT = '%s';
protected static
$_loadStr = array();
/**
* 获取跟定字符串的字节长度
*/
static public function length($str) {
return mb_strlen($str, PROJECT_ENCODE);
}
/**
* 获取跟定字符串的字符长度
*/
static public function width($str) {
return mb_strwidth($str, PROJECT_ENCODE);
}
/**
* 按字节长度截取指定字符串
*/
static public function cut($str, $length, $suffix = '...') {
$strLen = mb_strlen($str, PROJECT_ENCODE);
$suffixLen = mb_strlen($suffix, PROJECT_ENCODE);
if ($strLen <= $length || $strLen <= $suffixLen)
return $str;
return (mb_substr($str, 0, $length - $suffixLen, PROJECT_ENCODE)) . $suffix;
}
/**
* 按字符长度截取指定字符串
*/
static public function widthCut($str, $width, $suffix = '...') {
$strWidth = mb_strwidth($str, PROJECT_ENCODE);
$suffixWidth = mb_strwidth($suffix, PROJECT_ENCODE);
if ($strWidth <= $width || $strWidth <= $suffixWidth)
return $str;
$newStr = mb_strimwidth($str, 0, $width, $suffix, PROJECT_ENCODE);
return $newStr;
}
/**
* 驼峰命名
*/
static public function camelize($val, $split = '_', $firstUpper = true) {
if ($val == null) return $val;
if (strpos($val, $split) === false) return ($firstUpper ? ucfirst($val) : $val);
$val = str_replace('_', ' ', $val);
$val = ucwords($val);
$val = str_replace(' ', null, $val);
if (!$firstUpper)
$val = lcfirst($val);
return $val;
}
/**
* 反驼峰
*/
static public function tableize($val, $split = '_') {
$val = preg_replace('/([A-Z]{1})/e', ''_' . strtolower('\1')', $val);
if ($val{0} == '_') $val = substr($val, 1);
return $val;
}
/**
* 日期转日期的unix timestamp
*/
static public function date2num($date) {
$parse = date_parse($date);
return mktime($parse['hour'], $parse['minute'], $parse['second'], $parse['month'], $parse['day'], $parse['year']);
}
/**
* 生成字符缓存
*/
static public function buildStrCache($type) {
$name = "String/{$type}";
$file = MST_Core::getPathOf($name, MST_Core::P_LIB, '.txt');
if (is_file($file)) {
$str = file_get_contents($file);
$strAry = explode("
", $str);
$result = array();
foreach ($strAry as $line) {
$items = explode(',',$line);
for ($i = 1; $i < count($items);$i++) {
$result[$items[$i]] = $items[0];
}
}
return file_put_contents(MST_Core::getPathOf($name, MST_Core::P_LIB, '.php'), "<?php
return ".var_export($result, 1).";");
}
return false;
}
/**
* 读取字符缓存
*/
static public function getStrCache($type) {
if (!isset(self::$_loadStr[$type])) {
$file = 'String/' . $type;
self::$_loadStr[$type] = MST_Core::import($file, MST_Core::P_LIB, '.php');
}
return self::$_loadStr[$type];
}
/**
* 字符替换
*/
static public function charReplace($str, $type) {
if ($typeWords = self::getStrCache($type)) {
return str_replace(array_keys($typeWords), array_values($typeWords), $str);
}
return $str;
}
/**
* 生成指定字符内容的摘要信息
*/
static public function summary($content, $len = 256) {
$content = nl2br($content);
$content = strip_tags($content);
$content = str_replace(' ', ' ', $content);
$content = trim($content);
$content = preg_replace('/([
]+|[s]{2,})/i', ' ', $content);
$content = MST_String::cut($content, $len);
return $content;
}
}
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号