<?php
/*
* 中英文字符串的截取
*/
function sysSubStr($String,$Length,$Append = false)
{
if (strlen($String) <= $Length ) {
return $String;
}
else
{
$I = 0;
while ($I < $Length)
{
$StringTMP = substr($String,$I,1);
if ( ord($StringTMP) >=224 )
{
$StringTMP = substr($String,$I,3);
$I = $I + 3;
}
elseif( ord($StringTMP) >=192 )
{
$StringTMP = substr($String,$I,2);
$I = $I + 2;
}
else
{
$I = $I + 1;
}
$StringLast[] = $StringTMP;
}
$StringLast = implode(”",$StringLast);
if($Append)
{
$StringLast .= “…”;
}
return $StringLast;
}
}
function cut($Str, $Length) //$Str为截取字符串,$Length为需要截取的长度
{
global $s;
$i = 0;
$l = 0;
$ll = strlen($Str);
$s = $Str;
$f = true;
while ($i <= $ll)
{
if (ord($Str{$i}) < 0×80) {
$l++; $i++;
}
else if (ord($Str{$i}) < 0xe0) {
$l++; $i += 2;
}
else if (ord($Str{$i}) < 0xf0) {
$l += 2; $i += 3;
}
else if (ord($Str{$i}) < 0xf8) {
$l += 1; $i += 4;
}
else if (ord($Str{$i}) < 0xfc) {
$l += 1; $i += 5;
}
else if (ord($Str{$i}) < 0xfe) {
$l += 1; $i += 6;
}
if (($l >= $Length - 1) && $f) {
$s = substr($Str, 0, $i);
$f = false;
}
if (($l > $Length) && ($i < $ll)) {
$s = $s . ‘…’; break; //如果进行了截取,字符串末尾加省略符号“…”
}
}
return $s;
}
$String = “你好aaa”;
$Length = “5″;
echo cut($String,$Length);
?>
Tags: php, 中英混杂字符串截取
<?php
/*
* 直接返回
* $declaration 返回时的说明
*/
function ErrorBack($declaration)
{
$html = ‘
<html><head><title>提示信息</title>
<meta http-equiv=”content-Type” content=”text/html charset=utf-8″ />
<META HTTP-EQUIV=”pragma” CONTENT=”no-cache”>
<META HTTP-EQUIV=”Cache-Control” CONTENT=”no-cache, must-revalidate”>
<base target=”_self”/></head>
<body leftmargin=”0″ topmargin=”0″ bgcolor=”#FFFFFF”><center>
<div style=”border:1px solid #336699;width:550px;margin-top:25px;padding:1px;”>
<div style=”height:20px;font-size:16px;font-weight:bold;BACKGROUND:#1693D9;BORDER-BOTTOM:
#A8ECFF 2px solid;color:#FFFFFF;vertical-align:middle;padding:5px;”>- 提示信息 -</div>
<div style=”height:100px;font-size:14px;”><br/>
‘.$declaration.’
<br/><br/><a href=”javascript:history.go(-1);” mce_href=”javascript:history.go(-1);” style=”font-size:12px;color:#336699;”>
<u>系统将在2秒钟后自动跳转,如果你的浏览器没反应,请点击这里</u></a><br/><br/><div> </div>
<script>
var pgo=0;function JumpUrl(){if(pgo==0) location=\’javascript:history.go(-1);\’;pgo = 1;}
setTimeout(\’JumpUrl()\’,2000);
</script>
</center></body></html>
‘;
echo $html;
exit();
}
/*
* 返回到某个地址
* $declaration 返回时的说明
* $link 返回的地址
*/
function ErrorJump($declaration,$link)
{
$html = ‘
<html><head><title>提示信息</title>
<meta http-equiv=”content-Type” content=”text/html charset=utf-8″ />
<META HTTP-EQUIV=”pragma” CONTENT=”no-cache”>
<META HTTP-EQUIV=”Cache-Control” CONTENT=”no-cache, must-revalidate”>
<base target=”_self”/></head>
<body leftmargin=”0″ topmargin=”0″ bgcolor=”#FFFFFF”><center>
<div style=”border:1px solid #336699;width:550px;margin-top:25px;padding:1px;”>
<div style=”height:20px;font-size:16px;font-weight:bold;BACKGROUND:#1693D9;BORDER-BOTTOM:
#A8ECFF 2px solid;color:#FFFFFF;vertical-align:middle;padding:5px;”>- 提示信息 -</div>
<div style=”height:100px;font-size:14px;”><br/>
‘.$declaration.’
<br/><br/><a href=”‘.$link.’” mce_href=”‘.$link.’” style=”font-size:12px;color:#336699;”>
<u>系统将在2秒钟后自动跳转,如果你的浏览器没反应,请点击这里</u></a><br/><br/><div> </div>
<script>
var pgo=0;function JumpUrl(){if(pgo==0) window.location.href=\”.$link.’\';pgo = 1;}
setTimeout(\’JumpUrl()\’,2000);
</script>
</center></body></html>
‘;
echo $html;
exit();
}
?>
Tags: php, 跳转函数
<?php
/**
* @desc 阿拉伯数字转换成中文数字
*/
function num2Chinese($num)
{
static $_Chinese=array(’零’,'一’,'二’,'三’,'四’,'五’,'六’,'七’,'八’,'九’);
static $_List=array(’零’,'十’,'百’,'千’,'万’,'十万’,'百万’,'千万’,'亿’,'十亿’,'百亿’,'千亿’,'万亿’);
$lastLength=strlen($_List[0]);
$lastLength=0-$lastLength;
$num +=0;
$num=explode(’.',$num);
$num[0]=strrev($num[0]);
$num_length=strlen($num[0]);
$tmpArray=array();
$IF_LAST_ZERO=0;
$tmp=0;
$lastWord=”;
$lastKey=”;
for ($i=0;$i<$num_length;++$i)
{
$tmp=intval($num[0][$i]);
if($tmp==0)
{
if($IF_LAST_ZERO==0){
$tmpArray[]=($i==0?($num_length==1?’零’:”):’零’);
$IF_LAST_ZERO=1;
}
}
else
{
if($i==0)
$tmpArray[]=$_Chinese[$tmp];
else
{
$lastKey=substr($_List[$i],$lastLength);
if($lastKey==$lastWord){
$tmpArray[]=substr($_Chinese[$tmp].$_List[$i],0,$lastLength);
}
else{
$tmpArray[]=$_Chinese[$tmp].$_List[$i];
$lastWord=$lastKey;
}
}
$IF_LAST_ZERO=0;
}
}
$tmpArray=array_reverse($tmpArray);
if($num_length==2 && substr($tmpArray[0],0,0-$lastLength)==’一’)
$tmpArray[0]=substr($tmpArray[0],0-$lastLength);
if(sizeof($num)>1)
{
$tmpArray[]=’点’;
$num_length=strlen($num[1]);
for ($i=0;$i<$num_length;++$i)
{
$tmp=intval($num[1][$i]);
$tmpArray[]=$_Chinese[$tmp];
}
}
return join(”,$tmpArray);
}
$aa = num2Chinese(139087.0258);
echo $aa;
?>
Tags: php, 阿拉伯数字转换成中文数字
本地能搭建多个站点,需要修改 apache/conf/httpd.conf文件 和 Windows/system32/drivers/etc/hosts这2个文件.
1、 用写字本打开httpd.conf这个文件,在下面添加
NameVirtualHost 192.168.1.56
<VirtualHost 192.168.1.56>
DocumentRoot “F:/test”
ServerName www.w.com
</VirtualHost>
2.修改hosts文件在最后加上
127.0.0.1 www.w.com
Tags: apache, php, 搭建多个站点, 本地