首页 > 编程技术 > php

PHP5.3 snapshots

发布时间:2016-11-25 16:10

 

PHP5.3 snapshots

Antony Dovgal 指出 Derick Rethans 已经将php 5.3在snaps.php.net 上发布.
新增内容:Namespaces,__callstatic()魔术方法,通过$foo::myFunc()访问静态成员,类似于.htaccess的重写,OpenSSL扩展,PCRE7.4, 5.2版本中没有的其他的一些改进和修正.
他建议要十分彻底的调试过才发布release版.
源码版和windows版,已经在snaps.php.net发布.
 
 
 
 
 
 
Antony Dovgal''s Blog: 5.3 snapshots are available

Antony Dovgal points out that Derick Rethans has added the snapshots for PHP 5.3 to the snaps.php.net website.
Short list of what you can find there: Namespaces, __callstatic() magic method, accessing static members through $foo::myFunc(), fully rewritten ini-parser with .htaccess-like user defined ini files for CGI/FastCGI, improved OpenSSL extension, PCRE 7.4, and other fixes and improvements that will never get into 5_2 branch.
He recommends teching throughly before the major release to find all of the bug before the general public does. Builds for both source and Windows systems have been posted.
 
 



< PHP 截取字符串专题
作者: 不详 来源: 不详

1. 截取GB2312中文字符串
<?php
//截取中文字符串
function mysubstr($str, $start, $len) {
    $tmpstr = "";
    $strlen = $start + $len;
    for($i = 0; $i < $strlen; $i++) {
        if(ord(substr($str, $i, 1)) > 0xa0) {
            $tmpstr .= substr($str, $i, 2);
            $i++;
        } else
            $tmpstr .= substr($str, $i, 1);
    }
    return $tmpstr;
}
?>

2. 截取utf8编码的多字节字符串
<?php
//截取utf8字符串
function utf8Substr($str, $from, $len)
{
    return preg_replace(''#^(?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,''.$from.''}''.
                       ''((?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,''.$len.''}).*#s'',
                       ''$1'',$str);
}
?>

3. UTF-8、GB2312都支持的汉字截取函数
<?php
/*
Utf-8、gb2312都支持的汉字截取函数
cut_str(字符串, 截取长度, 开始长度, 编码);
编码默认为 utf-8
开始长度默认为 0
*/
 
function cut_str($string, $sublen, $start = 0, $code = ''UTF-8'')
{
    if($code == ''UTF-8'')
    {
        $pa = "/[x01-x7f]|[xc2-xdf][x80-xbf]|xe0[xa0-xbf][x80-xbf]|[xe1-xef][x80-xbf][x80-xbf]|xf0[x90-xbf][x80-xbf][x80-xbf]|[xf1-xf7][x80-xbf][x80-xbf][x80-xbf]/";
        preg_match_all($pa, $string, $t_string);
 
        if(count($t_string[0]) - $start > $sublen) return join('''', array_slice($t_string[0], $start, $sublen))."...";
        return join('''', <?php 

//定义一个excel文件 
$workbook "C:/My Documents/test.xls"
$sheet "Sheet1"

//生成一个com对象&ensp;$ex 
$ex = new COM("Excel.sheet") or Die ("连不上!!!"); 

//打开一个excel文件 
$book = &ensp;$ex->application->Workbooks->Open(&ensp;$workbook) or Die ("打不开!!!"); 

$sheets = &ensp;$book->Worksheets(&ensp;$sheet); 
$sheets->activate

//获取一个单元格 
$cell 感谢dxf218

我修正了其中一点点小小小的问题
<?php
/*
*    FileName                :    cache.inc.php
*    Link                    :   [url]http://blog.111cn.net/dxflingxing/[/url]
*    Author                    :   dxflingxing
*    Date                    :    2006-5-9
*    Last Modified            :    2006-5-16
*    Version                    :    1.0.1
*    Descrīption                :    Cache a page in file formart
*    Notice                    :    Make sure you cache file dir can be readed and wrote
*
*    Thanks to                :    小邪,barryonline(寒)
************************************************************
*
*    Usage                    :
*        # Cache active time half an hour
*        # This Can Auotmatic make some none exist dirs
*        # Or you can use an cache file in curent dir
*        # The Usage Such as
*        # $cache   
< 创建类似"../../../xxx/xxx.txt"的目录都很好!

function mkdirs($path, $mode = 0777) //creates directory tree recursively
{
$dirs = explode(''/'',$path);
$pos = strrpos($path, ".");
if ($pos === false) { // note: three equal signs
// not found, means path ends in a dir not file
$subamount=0;
}
else {
$subamount=1;
}

for ($c=0;$c < count($dirs) - $subamount; $c++) {
$thispath="";
for ($cc=0; $cc <= $c; $cc++) {
$thispath.=$dirs[$cc].''/'';
}
if (!file_exists($thispath)) {
//print "$thispath<br>";
mkdir($thispath,$mode);
}
}
}

原函数中使用$GLOBALS["dirseparator"]我改成了''/''


function recur_mkdirs($path, $mode = 0777) //creates directory tree recursively
{
//$GLOBALS["dirseparator"]
$dirs = explode($GLOBALS["dirseparator"],$path);
$pos = strrpos($path, ".");
if ($pos === false) { // note: three equal signs
// not found, means path ends in a dir not file
$subamount=0;
}
else {
$subamount=1;
}

for ($c=0;$c < count($dirs) - $subamount; $c++) {
$thispath="";
for ($cc=0; $cc <= $c; $cc++) {
$thispath.=$dirs[$cc].$GLOBALS["dirseparator"];
}
if (!file_exists($thispath)) {
//print "$thispath<br>";
mkdir($thispath,$mode);
}
}

}

 

<
标签:[!--infotagslink--]