What's New in PHP 5

Mac homebrew搭建php nginx apache mysql环境 macOS php nginx apache mysql 多版本 阅读详情
 翻译:深空
作者:Andi Gutmans, Stig Bakken, and Derick Rethans
不得擅自转载。

Introduction [绪论]
Language Features [语言特性]
? New Object Oriented model [新的面向对象模型]
? New Object Oriented Features [新的面向对象特性]
? Other New Language Features [其他新的语言特性]
General PHP changes [PHP 变化概要]
? XML and Web Services [XML 和 Web 服务器]
? New MySQLi (MySQL Improved) extension [新的 MySQLi (改良的 MySQL) 扩展]
? SQLite extension [SQLite 扩展]
? Tidy extension [Tidy 扩展]
? Perl extension [Perl 扩展]
? Other New Things in PHP 5 [其他 PHP5 新事物]
Summary [总结]



The best way to be ready for the future is to invent it. (John Sculley)
为未来作好准备的最好方法就是创造它。 (John Sculley)

Introduction [绪论]

Only time will tell if the PHP 5 release will be as successful as the releases of its two predecessors (PHP 3 and PHP 4). The new features and changes aim to rid PHP of any weaknesses it may have had and make sure that it stays in the lead as the best web scripting language on the globe.
只有时间能够证明 PHP5 是否和他的两个前辈(PHP3 和 PHP4)一样成功。新的语言特性和改变的目的是为了消除 PHP 可能已经具有的弱点, 和证实它作为全球最优秀的网页脚本语言所处的领先地位。

This book covers PHP 5 and its new features in great detail. However, for those of you familiar with PHP 4, and are eager to know what is new in PHP 5, then this chapter is for you.
这本书囊括了 PHP5 和它的新特性的详细描述。然而,作为 PHP4 的亲密好友的你都渴望知道 PHP5 究竟做了哪些更新,那么,这一章就是为你准备的。

The chapter will cover:
本章将包括:

  • The new language features [新的语言特性]
  • News concerning PHP extensions [关于 PHP 扩展的新消息]
  • Other noteworthy changes [其他值得注意的改变]

Language Features [语言特性]

New Object Oriented model [新的面向对象模型]

When Zeev Suraski added the object-oriented syntax back in the days of PHP 3, it was added as "syntactic sugar for accessing collections". The object-oriented model also had support for inheritance and allowed a class (and object) to aggregate both methods and properties, but not much more. When Zeev and Andi rewrote the scripting engine for PHP 4, it was a completely new engine, running much faster, much more stable and with many more features. However, the object-oriented model first introduced in PHP 3, was barely touched.
当 Zeev Suraski 在 PHP3 时期添加面向对象语法的时候,它被作为 "syntactic sugar for accessing collections" 添加。该面向对象模型也支持继承和允许类(或对象)聚合方法和属性,但没有更多的特性了。当 Zeev 和 Andi 为 PHP4 重写脚本引擎的时候,它是一个完全新的引擎,运行更快、更稳定,和集合了更多的特性。然而,面向对象模型首次在 PHP3 中引入,却极少涉及。

Although the object model had serious limitations it was used extensively around the world, often in very large PHP applications. This impressive use of the OOP paradigm with PHP 4 despite its weaknesses led to it being the main focus for the PHP 5 release.
虽然,对象模型已经严重限制了它在世界范围上的广泛使用--常常是非常大型的 PHP 应用程序,但是这个给人印象深刻的面向对象程序设计范例的应用和 PHP4 的缺点导致它成为 PHP5 发布版本的主要焦点。

So what were some of the limitations in PHP 3 & 4? The biggest limitation (which led to further limitations) was the fact that the copy semantics of objects were the same as for native types. So how did this actually affect the PHP developer? When you’d assign a variable (that points to an object) to another variable, a copy of the object would be created. Not only did this impact performance but it usually also lead to obscure behavior and bugs in PHP 4 applications because many developers thought that both variables would be pointing at the same object which wasn’t the case. They were pointing at separate copies of the same object, changing one would not change the other.
那么,PHP3 & PHP4 的局限性在哪里呢?最大的局限性(这导致更大的局限)是,事实上对象的拷贝和原始对象一样,因此这实际上影响了 PHP 的开发。当你将一个变量(它指向一个对象)赋值给另外一个变量的时候,这个对象的一个拷贝将被创建。在 PHP4 的应用程序里这样做不仅对执行产生影响,而且通常导致模糊的行为和错误。因为许多开发者认为这两个变量指向相同的对象(事实并不如此)。它们分别指向了这个对象的两个拷贝,改变其中一个并不能改变另外一个。

For example [比如]:

class Person {
    var
$name
;
    function
getName
() {
        return
$this->name
;
    }
    function
setName($name
) {
        
$this->name = $name
;
    }
    function
Person($name
) {
        
$this->setName($name
);
    }
}

function
changeName($person, $name
) {
    
$person->setName($name
);
}

$person = new Person("Andi"
);
changeName($person, "Stig"
);
print
$person->getName();

In PHP 4, this piece of code would print out "Andi". The reason is that we pass the object $person to the changeName() function by-value, and thus, $person is copied and changeName() works on a copy of $person.
在 PHP4 中,这段代码将打印 "Andi" 。原因是我们通过值将对象 $person 传递给函数 changeName(),那么,$person 的一个拷贝被创建,而 changeName() 运行了 $person 的这个拷贝。

This behavior is not very intuitive, as many developers would expect the Java-like behavior. In Java variables actually hold a handle (or pointers) to the object, and therefore, when it is copied only the handle and not the entire object is duplicated.
这种行为并不直观,很多开发者本来都以为它会像 Java 的方式一样运行。在 Java 里,变量实际上保持了对象的一个句柄(或者称指示器),因此它仅仅是作为一个句柄而不是全部被拷贝出来
There were two kinds of users in PHP 4, the ones who were aware of this problem and the ones who weren’t. The latter would usually not notice this problem and their code was written in a way where it didn’t really matter if the problem existed or not. Surely some of these people had sleepless nights trying to track down weird bugs which they couldn’t pinpoint. The former group dealt with this problem by always passing and assigning objects by reference. This would prevent the engine from copying their objects but would be quite a headache as the code included numerous ‘&’ signs.
PHP4 有两种不同类型的用户,一种知道这个问题而另一种却不知道。后者通常没有注意到这个问题,这个问题是否存在对于他们写的代码来说没有多大关系。的确,这类人中的一些人,通常整夜追捕那些他们不能确定的莫名其妙的错误。过去的团队通常通过给这个对象注册一个引用来处理这个问题。这将防止引擎创建对象的拷贝,但是有点头痛的是代码中包含了众多的 ‘&’ 标签。

The old object model not only led to the above-mentioned problems but also led to fundamental problems that prevented implementing some additional features on top of the existing object model.
旧的对象模型不仅仅导致上面提及的问题,而且阻碍了在这个已经存在的对象模型上实现一些附加的特性。

In PHP 5, the infrastructure of the object model was rewritten to work with object handles. Unless you explicitly clone an object by using the clone keyword you will never create behind the scene duplicates of your objects. In PHP 5, there is neither a need to pass objects by reference nor assigning them by reference.
在 PHP5 中,重写了对象模型的结构使它以对象句柄运行。除非你使用 clone 关键字确切地克隆了一个对象否则你根本不能创建对象的拷贝。在 PHP5 中,不需要传递对象的引用或者注册对象的引用。

Note: Passing by reference and assigning by reference is still supported, in case you want to actually change a variable’s content (whether object or other type).
注意:传递引用和注册引用仍然被支持,万一你要改变一个变量的内容(不管是对象或者其他类型)。

New Object Oriented Features [新的面向对象特性]

The new object oriented features are too numerous to give a detailed description in this section. The object oriented language chapter goes over each feature in detail.
新的面向对象特性实在太多了,不能在这一章节里详细阐述,面向对象语言章节将详细阐述每一个特性。

The following is a list of the main new features:
下面是主要的新特性列表:

1. public/private/protected access modifiers for methods and properties
1. 为方法和属性添加了 公共的/私有的/保护的 访问权限修饰

Allows the use of common OO access modifiers to control access to methods and properties.
允许使用公共的面向对象访问权限修饰来控制方法和属性的使用权限。

class MyClass {
    private
$id = 18
;

    public function
getId
() {
        return
$this->id
;
    }
}

2. Unified constructor name __construct()
2. 统一的构造器名: __construct()

Instead of the constructor being the name of the class, it should now be declared as __construct(), making it easier to shift classes inside class hierarchies.
代替了使用类名作为类的构造器的名称,它现在应该被声明为 __construct(),创建它比在类的层次上替换类更容易。

class MyClass {
    function
__construct
() {
        print
"Inside constructor"
;
    }
}

3. Object destructor support by defining a __destructor() method
3. 对象析构函数通过定义 __destructor() 方法得到支持

Allows defining a destructor function that runs when an object is destroyed.
允许定义一个析构函数当对象崩溃的时候运行。

class MyClass {
    function
__destruct
() {
        print
"Destroying object"
;
    }
}
?>

4. Interfaces
4. 接口

Gives the ability for a class to fulfill more than one is-a relationships. A class can inherit from one class only but may implement as many interfaces as it wants.
赋予类具有更多的相互关系。一个类只能从另外一个类中继承但是可以实现更多的想要的接口。

interface Display {
    function
display
();
}

class
Circle implements Display
{
    function
display
() {
        print
"Displaying circle "
;
    }
}

5. instanceof operator
5. 实例操作

Language level support for is-a relationship checking. The PHP 4 is_a() function is now deprecated.
提供 is-a 语言级别的检查支持,PHP4 中的 is_a() 函数现在不赞成使用。

if ($obj instance of Circle) {
    print
'$obj is a Circle'
;
}

6. final methods
6. final 方法

The final keyword allows you to mark methods so that an inheriting class can't overload them.
final 关键字允许你标记方法,使得继承类不能载入它们。

class MyClass {
    final function
getBaseClassName
() {
        return
__CLASS__
;
    }
}

7. final classes
7. final 类

After declaring a class as final, it can’t be inherited. The following example would error out:
在声明一个 final 类之后它们不能被继承,下面的例子将产生错误:

final class FinalClass {
}

class
BogusClass extends FinalClass
{
}

8. Explicit object cloning
8. 明确的对象克隆

In order to clone an object you have to use the clone keyword. You may declare a __clone() method which will be called during the clone process (after the properties have been copied from the original object).
为了复制一个对象你必须使用 clone 关键字。你可以声明一个 __clone() 方法,当一个类被拷贝的时候它将执行(在原对象属性被拷贝之后)。

class MyClass {
    function
__clone
() {
        print
"Object is being cloned"
;
    }
}
$obj = new MyClass
();
clone
$obj;

9. Class constants
9. 类常量

Classes definitions can now include constant values, and are referenced using the class.
类定义现在包含了常量定义,并且通过类来引用它们。

class MyClass {
    const
SUCCESS = "Success"
;
    const
FAILURE = "Failure"
;
}
print
MyClass::SUCCESS;

10. Static members
10. 静态成员

Classes definitions can now include static members (properties), accessible via the class. Common usage of static members is in the Singleton pattern.
类定义现在包含了静态成员(属性)的定义,并通过类访问它们。通常静态成员用于单独的部分。

class Singleton {
    static private
$instance = NULL
;

    private function
__construct
() {
    }

    static public function
getInstance
() {
        if (
self::$instance == NULL
) {
            
self::$instance = new Singleton
();
        }
        return
self::$instance
;
    }
}

11. Static methods
11. 静态方法

You can now define methods as static allowing them to be called from non-object context. Static methods don’t define the $this variable as they aren’t bound to any specific object.
你现在可以定义一个静态的方法,并且可以在没有对象的范围内被调用。静态方法没有定义 $this 变量作为其他特定对象的限制。

class MyClass {
    static function
helloWorld
() {
        print
"Hello, world"
;
    }
}
MyClass::helloWorld
();
?>

12. abstract classes
12. 抽象类

A class may be declared as abstract so as to prevent it from being instantiated. However, you may inherit from an abstract class.
类可以使用 abstract 声明防止它们被实例化。然而,你可以继承一个抽象类。

abstract class MyBaseClass {
    function
display
() {
        print
"Default display routine being called"
;
    }
}

13. abstract methods
13. 抽象方法

A method may be declared as abstract, thereby deferring its definition to an inheriting class. A class that includes abstract methods must be declared as abstract.
方法可以使用 abstract 声明,因此,从一个继承类延续他们的定义。一个类如果包含一个抽象方法必须用 abstract 声明。

abstract class MyBaseClass {
    
abstract function display
();
}

14. Class type hints
14. 类类型提示

Function declarations may include class type hints for their parameters. If the functions are called with an incorrect class type an error occurs.
函数声明可以包含类类星体是作为他们的参数,如果一个函数被一个错误的类调用将打印一个错误。

function expectsMyClass(MyClass $obj) {

}

15. Support for dereferencing objects which are returned from methods.
15. 支持从方法中返回非关联对象

In PHP 4, you could not directly dereference objects which are returned from methods. You would have to first assign the object to a dummy variable and then dereference it.
在 PHP4 中,你不能直接从一个方法中返回的对象中解析,你必须将这个对象注册给一个中间变量,然后解析它。
PHP 4:

$dummy = $obj->method();
$dummy->method2();

PHP 5:

$obj->method()->method2();

16. Iterators
16. 迭代

PHP 5 allows both PHP classes and PHP extension classes to implement an Iterator interface. Once you implement this interface you will be able to iterate instances of the class by using the foreach() language construct.
PHP5 允许 PHP 类和 PHP 扩展类执行一个迭代接口。一旦你执行这个接口,已将可以通过使用 foreach() 语言结构反复实例化这个类。

$obj = new MyIteratorImplementation();
foreach (
$obj as $value
) {
    print
"$value"
;
}

For a more complete example, please refer to the "Advanced OOP & Design Patterns" chapter.
查看一个更为完整的例子,请查阅“高级面向对象和设计模型”这一章节。

17. __autoload()
17. __autoload()

Many developers writing object-oriented applications create one PHP source file per-class definition. One of the biggest annoyances is having to write a long list of needed includes at the beginning of each script (one for each class). In PHP 5, this is no longer necessary. You may define an __autoload() function which is automatically called in case you are trying to use a class which hasn’t been defined yet. By calling this function the scripting engine is giving a last chance to load the class before PHP bails out with an error.
许多开发人员在写一个面向对象应用程序的时候,为每个类奖励以俄国 PHP 文件,其中一个最大的烦恼是,在每一个脚本的开始部分都要写一个很长的文件包含列表(一个类包含一次)。在 PHP5 中,这需要在这么做了。你可以定义一个 __autoload() 函数,它将自动调用一个还没有被定义的类。通过调用这个函数,脚本引擎将在 PHP 抛出一个错误之前一直持续尝试读取这个类。

function __autoload($class_name) {
    include_once(
$class_name . "PHP"
);
}

$obj  = new MyClass1
();
$obj2 = new MyClass2();

Other New Language Features [其他新的语言特性]

1. Exception handling
1. 异常处理

PHP 5 adds the ability for the well known try/throw/catch structured exception handling paradigm. You are only allowed to throw objects which inherit from the Exception class.
PHP5 添加了一个出名的 try/throw/catch 异常处理体系。仅允许你抛出一个继承自一个出现问题的类的对象。

class SQLException extends Exception {
    public
$problem
;
    function
__construct($problem
) {
        
$this->problem = $problem
;
    }
}

try
{
    ...
    
throw new SQLException("Couldn’t connect to database"
);
    ...
}
catch (SQLException $e
) {
    print
"Caught an SQLException with problem $obj->problem"
;
}
catch (Exception $e
) {
    print
"Caught unrecognized exception"
;
}

Currently for backwards compatibility purposes most internal functions do not throw exceptions. However, new extensions are making use of this capability and you can use it in your own source code. Also, similar to the already existing set_error_handler() you may use set_exception_handler() to catch an unhandled exception before the script terminates.
现在,为了向后兼容,绝大部分内部函数不会抛出异常。然而,为了使用这些功能,新的扩展正在被制定,你可以在自己的代码里使用它们。而且,和已经存在的 set_error_handler() 类似,你可以在脚本终止前使用 set_exception_handler() 来捕获一个未经处理过的异常。

2. foreach with references
2. foreach 与引用

In PHP 4, you could not iterate through an array and modify its values. PHP 5 supports this by allowing you to mark the foreach() loop with the ‘&’ (reference) sign, thus, making any values you change affect the array you’re iterating over.
在 PHP4 里,你不能迭代一个数组和改变它们的值。PHP5 允许你通过使用‘&’(引用)标记 foreach() 循环来实现,创建任何你改变的值影响你所迭代的数组。

foreach ($array as &$value) {
    if (
$value === "NULL"
) {
        
$value = NULL
;
    }
}

3. default values for by-reference parameters
3. 通过引用的参数的默认值

In PHP 4, default values could only be given to parameters which are passed by-value. Giving default values to by-reference parameters is now supported.
在 PHP4 中,参数只能通过值来接收默认值。现在给参数一个引用的值作为值得到支持。

function my_func(&$arg = null) {
    if (
$arg === NULL
) {
        print
'$arg is empty'
;
    }
}
my_func();

General PHP changes [PHP 变化概要]

XML and Web Services [XML 和 Web 服务器]

Following the changes in the language, the XML updates in PHP 5 are most probably the most significant and exciting. The enhanced XML functionality in PHP 5 puts it on par with other web technologies in some areas and overtakes them in others.
随着语言中的改变,XML 在 PHP5 中的更新大概最为重要和激动人心。PHP5 中增强的 XML 函数和相同领域里的其他 Web 技术一样,而且超过它们中的一部分。

The Foundation [基础]

XML support in PHP 4 was implemented using a variety of underlying XML libraries. SAX support was implemented using the old Expat library, XSLT was implemented using the Sablotron library (or using libxml2 via the DOM extension) and DOM was implemented using the more powerful libxml2 library by the GNOME project.
XML 在 PHP4 中通过底层的 XML 库得到支持;SAX 通过旧的 Expat 库得到支持;XSLT 通过 Sablotron 库(或者通过 DOM 扩展使用 libxml2)得到支持;而 DOM 通过使用更加强大的 GHOME 项目的 libxml2 库得到支持。

Using a variety of libraries did not make PHP 4 excel when it came to XML support. Maintenance was poor, new XML standards weren’t always supported, performance wasn’t as good as it could have been, and interoperability between the varies XML extensions did not exist.
使用这种种库并没有使 PHP4 在 XML 支持上优于他人。可维护性差,新的 XML 标准不总是被支持,性能不理想,和在这些扩展之间没有兼容性可言。

In PHP 5, all XML extensions have been rewritten to use the superb libxml2 XML toolkit (http://www.xmlsoft.org/). It is a very feature rich, highly maintained and efficient implementation of the XML standards bringing the cutting edge of XML technology to PHP.
在 PHP5 中,所有的 XML 扩展已经被重写并使用优秀的 libxml2 XML 工具包(http://www.xmlsoft.org/)。它具有非常丰富的特性。及高地保持和有效地实现 XML 标准为 PHP 带来了 XML 的优势。
All the above mentioned extensions (SAX, DOM and XSLT) now use libxml2 including the new additional extensions SimpleXML and SOAP.
所有上面提及的这些扩展 (SAX, DOM 和 XSLT) 现在使用 libxml2 --包含新的附加扩展 SimpleXML 和 SOAP。

SAX

As mentioned, the new SAX implementation has switched from using Expat to libxml2. Although the new extension should be compatible there may be some small subtle differences. Developers who still want to work with the Expat library can do so by configuring and building PHP accordingly (not recommended).
提起它,新的 SAX 的实现已经从 Expat 转到了 libxml2。虽然新的扩展在兼容性方面可能存在一些细微的差别。开发者仍然可以通过配置 PHP 来实现 Expat 扩展的支持(这并不被推荐)。

DOM

Although DOM support in PHP 4 was also based on the libxml2 library, it was quite buggy, had memory leaks and the API in many cases was not W3C compliant. The DOM extension went through a thorough facelift for PHP 5. Not only was the extension mostly rewritten it is now also W3C complaint. For example, function names now use studlyCaps as described by the W3C standard making it easier for you to read general W3C documentation and implementing what you learnt, right away in PHP. In addition, the DOM extension now supports three kinds of schemas for XML validation, DTD, XML Schema and RelaxNG.
虽然 DOM 支持在 PHP4 中仍然是基于 libxml2 的,但是它漏洞百出,存在着一个内存漏洞和由于多种原因 API 并不是依从于 W3C。DOM 扩展为 PHP5 做了彻底的改进,不仅仅几乎完全重写,而且现在也是 W3C 建议。比如,函数名现在通过 W3C 标准使用 studlyCaps 作为描述,使得你在 PHP 中更容易阅读总体的 W3C 文档,和执行你所学到的东西。

As a result of these changes PHP 4 code using DOM will not always run in PHP 5. However, in most cases adjusting the function names to the new standard will probably do the trick.
由于这些改变的原因,PHP4 中使用 DOM 的代码将不可能总是在 PHP5 中可用。然而,在大多数场合下,调整函数名到新的标准可能是个方法。

XSLT

In PHP 4, there were two extensions that supported XSL Transformations. The first was using the Sablotron extension and the second was using the XSLT support in the DOM extension. In PHP 5, a new XSL extension was written and, as mentioned, is based on the libxml2 extension. As in PHP 5, the XSL Transformation does not take the XSLT stylesheet as a parameter but depends on the DOM extension to load it, the stylesheet can be cached in memory and may be applied to many documents saving execution time
在 PHP4 中,有两个扩展支持 XSL 转化。第一个使用 Sablotron 扩展而第二个在 DOM 扩展中使用 XSLT 支持。在 PHP5 中,写了一个新的 XSL 扩展,提一下,它是基于 libxml2 扩展的。由于在 PHP5 中,XSL 转换不是提取 XSLT 样式作为一个参数而是依靠 DOM 扩展去读取它,这个样式会被存储到内存中并应用与许多文档来节约执行时间。

SimpleXML

Probably when looking back in a year or two it will be clear that SimpleXML has revolutionized the way PHP developers work with XML files. SimpleXML could really be called "XML for Dummies". Instead of having to deal with DOM or even worse SAX, SimpleXML represents your XML file as a native PHP object. You can read, write or iterate over your XML file with ease accessing elements and attributes.
大概,回顾过去一两年,我们会很清晰地知道,SimpleXML 已经改革了 PHP 开发者处理 XML 文件的方式。SimpleXML 能够被真正的叫做"XML for Dummies"。代替 处理 DOM 甚至更糟糕的 SAX,SimpleXML 将 XML 文件作为 PHP 对象来描述。你可以读取、写入或者使用迭代方便的访问元素和属性。

Consider the following XML file:
考虑下面的 XML 文件:

<clients>
<
client
>
    <
name>John Doe name>
    <
account_number>87234838 account_number>
client
>
<
client
>
    <
name>Janet Smith name>
    <
account_number>72384329 account_number>
client
>
clients>

The following piece of code prints each client’s name and account number:
下面的这段代码打印每个顾客的名字和帐号:

$clients = simplexml_load_file('clients.xml');
foreach (
$clients->client as $client
) {
    print
"$client->name has account number $client->account_number "
;
}

It’s obvious how simple SimpleXML really is.
这个例子明显体现了 SimpleXML 是多么的简单。

And in case there is something advanced you need to do to your SimpleXML object which isn’t supported in this lightweight extension, you can convert it to a DOM tree by calling dom_import_simplexml(), manipulate it in DOM and covert it back to SimpleXML using simplexml_import_dom(). Thanks to both extensions using the same underlying XML library switching between these two has been made a reality.
万一,你需要一些高级的特性作用于 SimpleXML 对象而它本身这种轻量级扩展并不支持。你可以通过调用 dom_import_simplexml() 将它转化为一个 DOM 树,使用 DOM 操作它然后使用 simplexml_import_dom() 转回给 SimpleXML。多亏了这两个扩展使用相同的底层 XML 库,在它们之间切换已经实现。

SOAP

Official native SOAP support in PHP 4 was lacking. The most commonly used SOAP implementation was PEAR’s but as it was implemented entirely in PHP it could not perform as well as a built-in C extension. Other available C extensions never reached stability and wide adoption and, therefore, were not included in the main PHP 5 distribution.
在 PHP4 中缺乏正式的 SOAP 支持。一般地使用 SOAP 是通过 PEAR 得到支持。但是,使用 PHP 作为实现并不能像使用内置 C 扩展一样出色。其他可用的 C 扩展不能达到稳定性而广泛的应用。因此 PHP5 的主配置没有把它包含进来。(这句好像有问题)

SOAP support in PHP 5 was completely rewritten as a C extension and, although it was only completed at a very late stage in the beta process, it was incooperated into the default distribution due to its thorough implementation of most of the SOAP standard.
SOAP 支持在 PHP5 中完全作为一个 C 扩展重写,虽然它仅仅在 BETA 版本后期中才完成。由于它彻底的实现 SOAP 的大部分标准,它已经被添加到默认配置。

The following calls SomeFunction() defined in a WSDL file:
下面调用一个 WSDL 文件中定义的 SomeFunction():

$client = new SoapClient("some.wsdl");
$client->SomeFunction($a, $b, $c);

New MySQLi (MySQL Improved) extension [新的 MySQLi (改良的 MySQL) 扩展]

For PHP 5, MySQL AB (http://www.mysql.com/) has written a new MySQL extension that allows you to take full advantage of the new functionality in MySQL 4.1 and later. As opposed to the old MySQL extension, the new one gives you both a functional and an object oriented interface so that you can choose what you prefer. New features supported by this extension include prepared statements and variable binding, SSL and compressed connections, transaction control, replication support and more...
为 PHP5,MySQL AB (http://www.mysql.com/)已经写了一个新的 MySQL 扩展,该扩展允许你使用 MySQL 4.1 或更新版本的新函数。与旧的 MySQL 扩展相对比,新的扩展提供给你一个函数和一个面向对象接口,因此你可以根据你的喜好来选择。该扩展支持新的特性,包括预声明和可变结合, SSL 和 连接压缩, 处理控制, 复制支持和其他很多特性。

SQLite extension [SQLite 扩展]

Support for SQLite (http://www.sqlite.org/) was first introduced in the PHP 4.3.x series. It is an embedded SQL library which does not require an SQL server and is very suitable for applications which don’t require the scalability of SQL servers or if you’re deploying at an ISP who doesn’t give you access to an SQL server. Contrary to what its name implies SQLite is very feature rich and supports transactions, sub-selects, views and large DB files. It is mentioned here as a PHP 5 feature because it was introduced so late in the PHP 4 series and as it takes advantage of PHP 5 by providing an object oriented interface and supporting iterators.
SQLite (http://www.sqlite.org/) 支持首先于 PHP 4.3.x 引入。它是一种嵌入式的 SQL 库,不包含 SQL 服务器而且非常适合不包含可伸缩性的 SQL 的应用程序、或者你正在使用不支持访问 SQL 的 ISP。对比它的名字,暗示着 SQLite 是一个具有丰富特性和事务支持、sub-selects、视图和大型的 DB 文件。在这里将它作为 PHP5 的新特性提及,是因为它在 PHP4 系列很后期才引入的,而且它通过提供一个面向对象接口来利用 PHP5 的优点和支持迭代。

Tidy extension [Tidy 扩展]

PHP 5 includes support for the useful Tidy (http://tidy.sf.net/) library. It allows PHP developers to parse, diagnose, clean and repair HTML documents. The Tidy extension supports both a functional and an object oriented interface, and it’s API uses the PHP 5 exception mechanism.
PHP5 包含一个很有用的 Tidy (http://tidy.sf.net/) 库支持。它允许 PHP 开发者分析、诊断、清理和修复 HTML 文档。Tidy 扩展支持函数和对象接口,而且它的 API 使用 PHP5 的异常机制。

Perl extension [Perl 扩展]

Although not bundled in the default PHP 5 package, the Perl extension allows you to call Perl scripts, use Perl objects and use other Perl functionality natively from within PHP. This new extension sits within the PECL (PHP Extension Community Library) repository a http://pecl.php.net/package/perl.
虽然没有综合评价默认的 PHP5 插件,Perl 扩展允许你从 PHP 内部调用 Perl 脚本、使用 Perl 对象和使用其他 Perl 功能。该新扩展位于 PECL (PHP 扩展公共库)仓库中。http://pecl.php.net/package/perl

Other New Things in PHP 5 [其他 PHP5 新事物]:

New memory manager
新的内存管理

The Zend Engine features a new memory manager. The two main advantages are better support for multi-threaded environments (allocations don’t need to do any mutual exclusion locks) and after each request freeing the allocated memory blocks is much more efficient. As this is an underlying infra-structure change you will not notice it directly as the end-user.
Zend 引擎特写了一个新的内存管理。两个主要的优点是更好的支持多线程环境(分配不需要再做任何互斥锁定),且在每个请求之后将更有效释放分配的内存单元。由于这是一个根本的底层构造改变,作为最终用户你不会很直接注意到这个变化。

Dropped support for Windows 95
放弃对 Windows 95 的支持

Running PHP on the Windows 95 platform is not supported anymore due to it not supporting functionality which PHP uses. As Microsoft has officially stopped supporting it over a year ago the PHP development community decided that this is a wise decision.
在 Windows 95 平台下运行 PHP 将不再被支持。因为它不支持 PHP 的功能。由于微软已经在一年前正式停止对 Windows 95 的支持,PHP 开发团队认为这是一个英明的决策。

Summary [总结]

You must surely be impressed by the amount of improvements in PHP 5. As mentioned earlier, this chapter doesn’t cover all of the improvements but only the main ones. Other improvements include additional features, a lot of bug fixes and very much improved infrastructure. The following chapters will cover PHP 5 and will give you in-depth coverage of the mentioned new features and others which were omitted.
你必定为 PHP5 的大量改进而感动。由于初期的叙述,该章节没有覆盖所有的而仅仅是主要的改进。其他还包括辅助特性的改进,一系列错误的修正和大部分的底层结构的改进。接下来其它章节将覆盖 PHP5 和给你一个新特性和其他遗漏的具体阐述。

 

Ubuntu 18.04 下 Ampache 部署实战:Apache+PHP7.2+MySQL5.7 稳定架构详解 Web服务器是承载PHP应用的基础运行环境,其配置直接影响流媒体服务的稳定性与可维护性。Apache作为成熟稳定的LAMP核心组件,凭借原生.htaccess支持、模块化加载机制和对传统PHP应用的深度适配,在音乐元数据管理类场景中展现出独特优势。PHP版本兼容性与MySQL字符集协同是关键技术价值——PHP 7.2保障Ampache插件生态稳定运行,utf8mb4字符集则确保中文歌名、歌词及用户评论的完整存储与检索。该方案广泛适用于家庭NAS音乐中枢、中小团队内部共享平台及轻量级毕业设计项目,尤其适合需要 阅读详情

相关推荐

NOAA气象数据下载攻略

各方搜寻气象数据下载途径,发现网上最多的就是从NOAA下载,但是中途有尝试过很多次都没有下载到,每次都是显示不可用,今天终于下载成功了,特此记录。 首先我是从这个网址进入的:National Centers for Environmental Information (NCEI) formerly known as National Climatic Data Center (NCDC) | NCEI offers access to the most significant archives of oc

lianqian66的博客 3万+

PHP 5.4 is Here! What You Must Know

PHP 5.4 is here; the next major step forward since version 5.3 – keeping PHP 6 (full Unicode support) on hold for now. The latest enhancements significantly improve its elegance, while removing deprec

精彩人生 949

MoveIt2项目想换掉KDL求解器?试试这个trac_ik插件(附源码编译避坑指南)

本文详细介绍了如何在MoveIt2项目中用trac_ik插件替代KDL求解器,提升机械臂运动学求解的效率和成功率。内容涵盖环境准备、源码编译避坑、项目集成及性能调优,特别适合需要高精度控制的协作机械臂应用场景。通过实测数据对比,trac_ik在求解时间和奇异点处理上显著优于传统KDL求解器。

weixin_30730053的博客 706

what is php,what is php doing.

有些时候,当你运行一个php脚本时,你可能想知道这个脚本到底在捣鼓什么。有些工具可以帮助你不停脚本弄清楚它。这些工具有些只能再linux上工作。stace 第一个工具是stace。stace是一个可以追踪系统调用的工具。系统调用主要是php读写网络端口或者文件;也包括通过网络和域套接字读写数据库。strace也会显示其他的系统调用比如time。stace的使用方法:strace -p proces...

weixin_34394265的博客 124

抄表程序员的DLMS/COSEM协议实战:从抓包到解析,手把手教你读懂IEC62056报文

本文深入解析DLMS/COSEM协议在智能电表通信中的应用,从报文捕获到数据解析的全流程实战指南。涵盖HDLC帧解析、应用层连接建立、数据请求/响应解码等核心内容,并提供Wireshark配置、OBIS代码速查表等实用工具,帮助开发者快速掌握IEC62056标准下的电能表通信技术。

weixin_29178069的博客 306

VS2022错误列表高效处理:从复制到Excel表格的完整指南

本文详细介绍了在Visual Studio 2022中高效处理错误列表的实用技巧,重点讲解了如何将错误信息一键复制并粘贴到Excel表格中。通过基础操作、自定义视图、筛选功能及常见问题解决方案,帮助开发者将杂乱的编译错误整理成清晰、可排序、可筛选的数据表,极大提升了团队协作、错误分析和项目管理的效率。

weixin_28837817的博客 363

what is php and what can php do ?,PHP and COM (转)

PHP and COM (转)[@more@]can be used to access and DCOM s on platforms1.I have built a DLL to calculate something. Is there any way to run this DLL under PHP ?If this is a simple DLL there is no way ye...

weixin_39628594的博客 147

Python爬虫教程:抓取电商网站评论(以淘宝和京东为例)

通过本文的介绍,我们学会了如何使用Python编写爬虫,抓取淘宝和京东等电商平台的商品评论数据。我们介绍了如何使用电商平台提供的开放API以及如何通过模拟浏览器来抓取动态加载的数据。此外,我们还讨论了如何应对反爬虫技术,如何存储抓取的数据等。爬取电商平台的数据是一个强大的工具,能够为市场分析、消费者行为研究、产品优化等领域提供有力的支持。然而,在使用爬虫技术时,我们必须遵循法律法规,尊重平台的隐私政策,避免滥用数据。

2201_76125261的博客 1741

Python 最近两条好消息:①TIOBE排名超过C和Java②新版本发布3.10.0,还有今天刚发布的《What’s New in Python(2021.10.15)》

来自TIOBE的最新10月份统计数据显示,Python首次超越Java、JavaScript、C语言等,成为最受欢迎的编程语言。TIOBE过去20年一直在追踪编程语言的受欢迎程度,其数据来自于对25个搜索引擎和网站的检索结果,包括但不限于谷歌、必应、维基百科、雅虎、油管等。Python最近的份额占比是11.27%,C语言是11.16%,Java以10.4排第三;TOP10中还有C++、C#、Visual Basic、JavaScript、SQL、PHP和Assembly。 2021年10月04日,..

汉阳Hann's Home 2450

实验2 存储器设计与实现【计算机组成原理】

实验2 存储器设计与实现【计算机组成原理】

小心星的博客 2405

SpringBoot实战教程-springboot概论

Spring Boot 是一个快速开发框架,能够快速的整合第三方框架,简化XML配置,全部采用注解形式,以及自动配置。内置web容器,帮助开发者能够实现快速开发,简化了应用系统的初始搭建以及开发过程。

鸟哥哥的专栏 4169

What is PHP Composer

If you have ever written anything in PHP before, you have probably found that it feels like you have to keep re-inventing the wheel anytime you want to do a common task such as User Authentication, Da

kevin@hbstu.net 932

LLC变压器,常见的4大问题解决方案

其中之一是当付边的绕组的匝数或层数较多的时候,层间或匝间寄生电容和付边的漏感发生一个寄生的振荡,轻载的时候,这个振铃的幅度会达到很高,导致输出电压比设计的要高许多。但当输入是低压的时候,开关频率比较低,LLC谐振回路的增益较大,因而比较容易发生变压器饱和的问题。由于LLC变压器工作在LC谐振状态,LC谐振回路有个特点就是Q值问题,在这里Q值是大于1的,因而就会有实际加在变压器上的电压要比输入电压高的问题,因而在设计变压器的时候就必须考虑到这一点,否则变压器就不是工作在你设计的磁感应强度上。

1277

php sql server 2012_What SQL Server 2012 Means for PHP Developers

What SQL Server 2012 Means for PHP Developers03/12/20125 分钟可看完本文内容Last week, Microsoft held a virtual conference to announce the availability of SQL Server 2012. The conference included a number of ev...

weixin_39982568的博客 167

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

what is php doing.

有些时候,当你运行一个php脚本时,你可能想知道这个脚本到底在捣鼓什么。有些工具可以帮助你不停脚本弄清楚它。这些工具有些只能再linux上工作。 stace 第一个工具是stace。stace是一个可以追踪系统调用的工具。系统调用主要是php读写网络端口或者文件;也包括通过网络和域套接字读写数据库。strace也会显示其他的系统调用比如time。stace的使用方法: strace -p p

NewHope, NewLife 780

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

In PHP you can combine arrays using + or you can use array_merge. What’s the difference?

from  https://www.texelate.co.uk/blog/combining-arrays-using-plus-versus-array-merge-in-php There are some differences between using associative arrays and sequential arrays. Associative arrays first...

weixin_36224759的博客 189

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

php_memcache-5.3-vc6-x86,php startup memcache unable to initialize module 解决方案

compiled with moduleAPI=20090626 These options need to match in Unknown on line 0 bogustest name tests/ps.用5.2.x版本都好好,切换到5.3.x就无法使用了!原因与解决方案如下:原因:When you update the version of PHP(especiallywhen goi...

weixin_39673293的博客 370

PHP - PHP-FPM - 学习/实践

本文摘要: 文章主要探讨了Nginx+PHP-FPM的运行机制、配置优化与实践应用。首先介绍了PHP-FPM作为PHP FastCGI进程管理器的工作原理,对比了CGI与FastCGI的区别,强调FastCGI通过主进程管理worker进程提升性能。详细解析了php-fpm.conf配置文件结构及核心参数,包括进程管理、日志设置等。同时展示了Nginx与PHP-FPM的协同配置,特别是虚拟主机多站点部署。文中还讨论了PHP-FPM的进程模型(master+worker)、平滑重启方法,以及常驻内存特性与Sw

"代码"的日常搬运 2295

实测Agents-A1-5bit性能:13万上下文下98.2 tok/s,M5 Max设备表现惊艳

Agents-A1-5bit是基于MLX框架的5位量化视觉语言模型,专为高效处理多模态任务设计。在MacBook Pro M5 Max设备上,该模型展现出令人惊叹的性能表现,即使在13万上下文长度下仍能保持98.2 tok/s的解码速度,为开发者和AI爱好者提供了强大而经济的本地运行方案。 ## 模型简介:5位量化的视觉语言专家 Agents-A1-5bit源自InternScience/Ag

gitblog_00629的博客 873

Phalcon之 提高性能:下一步该做什么?(Increasing Performance: What’s next?)

Phalcon中如何提升web应用性能

qzfzz的博客 2165

what_we_can_do.

0x01、Web 1.序言 a:1:{i:0;s:3:"123";} array (size=1) 0 => string '123' (length=3) a:1:{i:0;s:3:"123";}???? array (size=1) 0 => string '123' (length=3) a:1:{i:0;s:3:"123";}";} array (size=1) 0 => string '123' (length=3) 2.what_we_can_do. 第

qwsn 1618

What are the requirements for audio output in Chrome on Android?

Chrome在Android上音频输出的要求是什么?

suiusoar 556

what-changed 项目教程

what-changed 项目教程 1. 项目的目录结构及介绍 what-changed/ ├── bin/ │ └── example/ ├── lib/ │ └── tests/ ├── github/ │ └── workflows/ ├── .gitignore ├── .php_cs.dist ├── CHANGELOG.md ├── LICENSE ├── README.m...

gitblog_00046的博客 398

AngularJS+PHP实现Mapcode数字地址生成器

数字地址是一种将地理坐标映射为短字符串的地理编码技术,其核心原理是基于球面网格划分与混合进制编码,具备全球唯一、长度固定、可逆解码等特性。该技术显著提升地址存储效率、降低系统耦合度,并在物流调度、政企内网、低带宽场景中展现出独特工程价值。本文聚焦于使用 AngularJS 与 PHP 落地 Mapcode 标准的轻量级实现,深入解析大小写敏感索引、MySQL 表碎片治理、幂等生成逻辑等生产级细节,尤其适配存量系统改造与自主可控部署需求。

cihongmo6452的博客 381

听 Fabien Potencier 谈Symfony2 之 《What is Symfony2 ?》

Symfoy2 是什么? PHP世界里又一广受关注的web MVC框架? Fabien Potencier 却不这么说! Fabien Potencier这样定义Symfoy2 是个什么东西: 首先,Symfony2 是一个独立,松散的,有组织严密的PHP组件集合,它可以为你解决一些web开发中遇到的一般性问题。 其次,基于这些组件,Symfoy2 也可以作为一个独立的web框架使用。 那么S...

huidaoli 1637

一文读懂siglip_so400m_patch14_384项目文件:config.json、spiece.model与预处理配置全解析

siglip_so400m_patch14_384 是 Google 提出的 SigLIP 多模态模型(SoViT-400m 架构,384×384 分辨率)的官方权重仓库,开箱即可用于零样本图像分类与图文检索。本文将带你逐个拆解仓库里的核心文件:模型结构配置 [config.json](https://link.gitcode.com/i/f7b8b99627d6fd08f9a92d4d9e8c5

gitblog_00310的博客 976
下一篇: PHP初学者之路--认识 Class
countstars
博客等级 码龄24年 8粉丝 24原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值