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.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生成excel文件
<?
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
e ......
PHP中的MYSQL常用函数总结
1、mysql_connect()-建立数据库连接
格式:
resource mysql_connect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]])
例:
$conn = @mysql_connect("localhost", "username", "password") or dir( ......
今天给大家介绍的事一款来自美国的豪华主机空间,空间类型是PHP的,速度很快,主机配置也很好(4CPU)!
闲话不说了,看免费空间介绍吧:
空间大小:5GB
月流量:10GB
免费MySQL数据库: 无限制
支持脚本:CGI, PHP, FrontPage Extensions, Perl, Python.
支持FTP
支持域名绑定
有免费邮局,是cPanel面板的,支 ......