易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP截取固定长度字符串函数

<?php   
  
function toFixLen($str,$len){ //固定长度字符串的截取   
  
    if($len>=strlen($str)||!$len) return $str;   
  
    $len-=3;   
  
    $tempstr1 = substr($str,0,$len); //截取字符串   
  
    $tempstr2 = preg_replace('/([\x81-\xff]+)$/ms','',$tempstr1,1); //去掉结尾的连续汉字字符   
  
    if(!is_int((strlen($tempstr1)-strlen($tempstr2))/2)){ //去掉的字符为奇数?   
  
        $tempstr1 = substr($str,0,$len-1);   
  
    }   
  
    return $tempstr1."…";   
  
}   
  
?>


相关文档:

php soap初识

打开php.ini的soap扩展
server.php
<?php
class math{

/**
* 加法
*
* @param integer $a
* @param integer $b
* @return integer
*
*/
public function add($a, $b){

return $a + $b;
}
}
$server = new SoapServer('http://localhost/math.wsdl',array('soap_version' =& ......

【PHP系列教程】(4)——PHP的变量

很荣幸上篇文章被版主推荐到首页了,心里算是激动了一把,继续努力学习中吧。本章主要介绍PHP中的变量。主要包括:预定义变量、变量范围、可变变量以及PHP的外部变量等。
一、基础知识
PHP 中一个美元符号后面跟上一个变量名称,即表示一个变量。变量的名称是对大小写敏感的。
变量名与 PHP 中其它的标签一样遵循相同的 ......

PHP中getenv()函数

getenv()   取得系统的环境变量(预定义变量)
$spager=getenv('SERVER_NAME');
“PHP_SELF”
当前正在执行脚本的文件名,与 document root 相关。举例来说,在 URL 地址为 [url]http://example.com/test.php/foo.bar[/url] 的脚本中使用 $_SERVER['PHP_SELF'] 将会得到 /test.php/foo.bar 这个结 ......

PHP 面试题及答案

简述题(50分)()
1、用PHP打印出前一天的时间格式是2006-5-10 22:21:21(2分)
echo date('Y-m-d H:i:s', strtotime('-1 day'));
或者
$yesterday = time() - (24 * 60 * 60);
echo 'today:'.date('Y-m-d H:i:s')."\n";
echo 'yesterday:'. date('Y-m-d H:i:s', $yesterday)."\n";
2、echo(),print(),print_r()的区别( ......

php表达式之explode() 分割字符串

原帖地址:http://www.phpma.com/english/20071215/640.html
Description
array explode
( string separator, string string [, int limit])phpma.com
Returns an array of strings, each of which is a substring of string
formed by splitting it on boundaries formed by the string separator
. If limit
is ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号