PHP

浏览模式: 标准 | 列表 | 图文
好不要脸的说明

好不要脸的说明

何谓开源?网上有多种说法,但从字面意义来说,就是:开放源代码。
我们看看百科上怎么说:


关于开放源代码的定义(1.7版)

开放源代码并不仅仅意味着对源代码的访问权。开放源代码软件的发布条款必须满足以下条件:

1. 自由地再发布

如果被发布的软件是由不同来源的程序组成的,许可证不得限制任何当事人或组织(party)销售或赠送作为被发布软件成分之一的开放源码软件。

许可证不得从此项销售中索取使用费或其它任何费用。(理由)

2. 源代码

程序必须包括源代码,必须允许以源代码方式发布、还必须允许以编译后的形式发布。如果产品的某个部分没有与源代码一同发布,那么必须提供通行的、不需要支 付合理范围之外的任何费用的手段以获得源代码---从网络上免费下载是一种可取的方式。源代码必须是程序员对其进行修改的最佳形式。故意地使源代码变得含 混晦涩是不允许的。也不允许给出预处理器或翻译器处理的中间结果。(理由)

3. 派生作品

许可证必须允许修改软件和派生软件,并且必须允许它们按照原软件的许可证的条款进行发布。(理由)

4. 作者的源代码的完整性

只有在许可证允许与源代码一同发布"补丁文件"(该"补丁文件"以在创建时对程序进行修改为目的)时,许可证才能限制对修改形式的源代码的发布。许可证必 须明确地允许发布由修改后的源代码生成的程序。许可证可以要求派生的作品采用不同的名称或不同的版本号以区别于原来的软件。(理由)

5. 不得歧视任何个人或团体

许可证不得歧视任何个人或者由多人组成的团体。(理由)

6. 不得歧视任何应用领域(fields of endeavor)

许可证不得限制任何人把程序应用于任何领域。例如,不得规定程序不能应用于商业领域或基因研究领域。(理由)

7. 许可证的发布

与程序有关的权利必须适用于该程序的任何使用者,并且程序的使用者也不需要为了使用该程序而获得其它许可证的许可。(理由)

8. 许可证不能针对于一个产品

与程序有关的权利不能由该程序是否作为某个软件产品的一部分来决定。如果程序从那个发布中被抽出来,并且按照程序的许可证的条款进行使用和发布,那么得到该程序的当事人或组织将获得与得到原程序的使用者相同的权利。(理由)

9. 许可证不能影响其它软件

许可证不得向与采用它的软件一同发布的其它软件提出任何限制。例如,许可证不能坚持要求在同一媒体上发布的其它程序都是开放源代码软件。(理由)

Conformance

(本节不是开放源代码定义的一个部分)

我们认为本开放源代码定义涵盖了由绝大多数软件团体使用的术语"开放源代码"的最初含义和当前含义。然而,该术语被广泛地应用,并且它的含义变得不精确 了。OSI Certified标志是某个软件发布许可证是否服从开放源代码定义的OST认证方式。一般的术语"开放源代码"并不提供这种担保,但我们仍然鼓励使用" 开放源代码"这一术语以表明它符合"开放源代码定义"。关于OSI Certified标志的信息,以及已经通过了OSI Certified、符合"开放源代码定义"的许可证,请参见OSI Certified标志与纲要。

开放源代码定义之原理

给出开放源代码的定义的目的是:把我们所确信的、由软件开发团体所公认的"开放源代码"的含义作为一组具体的准则写下来---该准则确保按照开放源代码许 可证发布的软件可以得到与其它软件同样认真的评审、使软件可以不断地得到改良和遴选,从而提供非开放软件所难以提供的可靠性与能力。

为了使此项工作持续发展,我们必须抵制人们为了短期利益而中止为软件开发做出贡献。这意味着,许可证的条款必须防止人们藏匿(lock up)源代码从而导致只有很少的人才能够阅读和修改它。

当软件的开发者按照由OSI认证的许可证发布他们的软件时,他们可以在软件中使用"OSI Certified"标志。这种认证标志告知用户,该软件所采用的许可证符合开放源代码定义。关于我们的认证标志的更多信息及其纲要,请参见OSI Certified标志与纲要。

1. 自由地再发布

通过强制要求许可证允许自由地再发布,我们抵制了任何为了获得少量短期销售金额而放弃长期效益的诱惑。如果我们不这样做,就会有很多压力迫使合作者放弃承诺。

2. 源代码

由于软件只有通过修改才能够得到改进,因此我们要求获得易于理解的源代码。因为我们的目的是使软件易于改进,我们也就希望软件易于修改。

3. 派生作品

仅仅提供可以阅读的源代码,对于实施认真的评审、对于软件的快速改良与遴选来说都是不够的。为了加快改进软件的速度,人们需要能够进行试验和对修改进行重新发布。

4. 作者的源代码的完整性

鼓励对软件进行各种改进是一件好事,但使用者有权知道谁应该对他们所使用的软件负责。软件的作者和维护者都有权知道需要他们提供支持的软件是什么,以维护他们的名誉。

因此,开放软件许可证必须保证可以容易地得到源代码,但可以要求源代码以原始源代码和一组补丁文件的形式发布。按照这种方式,就可以获得"非正式的"的修改而同时又可以轻易地把它们从原始源代码中区分出来。

5. 不得歧视任何个人或团体

为了从该进程中获得最大的收益,应该给尽可能多的个人和团体以同等资格对开放源代码软件做出贡献。为此我们禁止开放源代码许可证把任何人排除在这个进程之外。

6. 不得歧视任何应用领域(fields of endeavor)

该条款的主要目的是禁止许可证中含有使开放源代码软件无法在商业上使用的规定。我们需要商业用户参与我们的工作,而不让他们感到被排除在外。

7. 许可证的发布

本条款的目的是禁止通过非直接的手段,例如需要签署非公开的协定,使软件无法公开。

8. 许可证不能针对于一个产品

本条款用于预防其它许可证陷阱。

9. 许可证不能影响其它软件

开放源代码软件的发布者有权为他们自己的软件做出选择。

是的,GPL满足这条要求。按GPL发布的库只影响(contaminate)在运行时与之连接的软件,于仅仅和它一同发布的软件无关。

OSI Certified标志与纲要

开放源代码定义给出了开放源代码软件的基本性质。不幸的是,术语"开放源代码"遭到了滥用,并且由于它的描述性,它不能作为一个商标(这是我们的首选)被 保护。由于社团需要一种可靠的方式以确定一份软件是否真正是开放源代码软件。OSI为此目的而注册了一个认证标志,OSI Certified。如果你在一份软件上看到了该标志,那么该软件就是必定是按照遵从开放源代码定义的许可证发布的,否则,该发行人就是在滥用该标志而且 违反了法律。

OSI Certified标志被用于软件而不是许可证:人们需要知道的是组成软件的包和它们的许可证是开放的源代码。此外,单独的许可证可能不是"货物",它由 美国专利和商标局注册认证标志。但是软件的作者显然必须能够在不询问我们的情况下(自我认证)、在适当的时刻确认他们的软件是按照OSI Certified的开放源代码方式发布的。所以认证按照两步进行:

* OSI提供一个满足开放软件源代码定义的开放源代码许可证表。这些许可证经过公众的详细审查并且被我们所批准。如果你有一个希望加入该列表的许可证,请与license-approval@opensource.org联系,它启动了获得许可证批准的程序。

* 如果你希望在你的软件上设置OSI Certified标志,你可以从列表中选择一个获得批准的许可证并根据它发布软件,并且适当地为软件做标志。

上面仅仅是一个概括。下面给出申请批准许可证和把OSI Certified标志应用在你的软件上的详细说明。

获得许可证的批准

1.通过电子邮件把许可证发送给license-approval@opensource.org。在电子邮件中说明你是否愿意以你的签名或者匿名地把许 可证发送到许可证讨论列表中。(我们愿意考虑那些根本不希望被发送的许可证,但由于社团的评审是批准的一个重要组成部分,我们将不得不把该许可证私下地发 送给评审者:因此,对没有被发送到许可证讨论列表中的许可证的批准,要花费更长的时间,并且通常要更多地与你交流。)

2. 如果我们发现你的许可证不符合开放源代码的定义,我们将与你一同解决这个问题。

3. 同时,我们将关注许可证论坛列表,并且与你一同工作以解决大家提出的任何未包含的问题。

4. 作为该过程的一部分,我们还将就许可证问题向外界寻求法律上的建议。

5. 一旦许可证符合了开放源代码定义,并且在许可证论坛上经过了充分的讨论或者其它的评审者没有提出我们认为重要的问题,我们将通知你,许可证已经被批准了,同时它被复制到我们的网站上,并且被加入以下的许可证列表。

使用该标志

你可以在这两种软件的发行上使用OSI Certified标志。该软件的发布包括并且达到了被批准的许可证列表中某个许可证的要求,或者该软件的源代码已经被明确地放到公众可以得到的位置。

为了表明你的软件是按照OSI Certified发布的,你必须不加任何修改地把下面两者之一,按照下述方式加入你的软件。完整的声明是:

This software is OSI Certified Open Source Software.

OSI Certified is a certification mark of the Open Source Initiative.

较简短的声明是:

OSI Certified Open Source Software

你的软件的每种发布形式都有自身的要求:

* 如果软件以电子的形式发布(而不是实物(tangible)的形式),你必须把完整的声明放在README文件或者类似的、人类用户将首先阅读的文件中。

* 如果软件以实物形式发布,你必须完成以下所有可行的任务:

* 如果软件的发布包括印刷品,你必须把完整的声明加入该印刷品。

* 如果软件发布在可擦写的媒体(例如软磁盘)、CD-ROM、磁带等媒体上,它们在物理上可以添加能够被人的裸眼所阅读的简短声明,而不影响它们的功能,你必须把完整的声明或简短的声明标注在该媒体上。

* 如果软件的发布是一个的包,从而使其中的声明不能被阅读。你必须在包的外面放置完整的声明。

如果不能把以上任何条款用于发布,请与我们联系,我们将把你选择的位置加入本列表。

获得批准的许可证

以下许可证满足开放源代码的定义,并且已经被批准用于OSI Certified的开放源代码软件。没有给出批准日期的许可证是在1999年1月1日以前批准的。

* The GNU General Public License(GPL);

* The GNU Library(Lesser) General Public License(LGPL);

* The BSD License;

* The X Consortium License;

* The Artistic License;

* The Mozilla Public License(MPL);

* The QPL;

其它符合定义的许可证包括:libpng许可证、zlib许可证、IJG JPEG许可证和OPL(Open LDAP Public License)许可证。


看看shopNC官方怎么说:我们是开源作品。确实,你是开源了,但你只开了几个目录的代码就叫开源吗?
真是有中国特色啊。

如果你自己没有自信,那你完全可以不开源。不开源本来就无所谓的,只是用这种欺骗的手段,好象有点。。。。

REST与SOAP之比较——SOAP篇

REST与SOAP之比较——SOAP篇

比较REST和SOAP的“风格”

REST依赖一套简单的“动词”,把所有的复杂性都转移到了指定资源的“名词”中。与此不同,SOAP却有一套相当复杂的XML格式化命令和数据传输选项。

在Web服务发展的初期,XML格式化消息的第一个主要用途是,应用于XML-RPC协议,其中RPC代表远程过程调用。在XML远程过程调用(XML-RPC)中,客户端发送一条特定消息,该消息中必须包括名称、运行服务的程序以及输入参数。相反, REST风格的请求却不关心正在运行的程序是什么,它仅仅请求命名资源。

XML-RPC只能使用有限的数据类型种类和一些简单的数据结构。人们认为这个协议还不够强大,于是就出现了SOAP——其最初的定义是简单对象访问协议。之后,大家逐渐意识到SOAP其实并不简单,而且也不需要必须使用面向对象语言,所以,现在人们只是沿用SOAP这个名称而已。

XML-RPC只有简单的数据类型集,取而代之,SOAP是通过利用XML Schema的不断发展来定义数据类型的。同时,SOAP也能够利用XML 命名空间,这是XML-RPC所不需要的。如此一来,SOAP消息的开头部分就可以是任何类型的XML命名空间声明,其代价是在系统之间增加了更多的复杂性和不兼容性。

另外,非常重要一点是,REST是需要请求HTTP的,与其相比,SOAP更具优势,SOAP消息可以由所有能够处理Unicode文本的传输方式来传送,很可惜,这一点通常不被人们所认可。事实是,由于HTTP穿透防火墙的便捷性,以及开发商们对Web非常熟悉,因此,人们还在继续强调着HTTP传输。

随着计算机行业的觉醒,人们发现了基于XML的Web服务的商业潜力,于是,各家公司开始不断地发掘想法、观点、论据以及标准化尝试。W3C曾经设法以“Web服务活动”的名义来组织成果展,其中也包括实际做出SOAP的XML协议工作组(XML Protocol Working Group)。与Web服务有关的标准化成果——从某种程度上说与SOAP相关或者依赖于SOAP——的数量已经倍增了到了令人惊讶的程度。

最初,SOAP是作为XML-RPC的扩展而发展起来的,它主要强调的是,通过从WSDL文件中所获得的方法和变量名来进行远程过程调用。现在,通过不断进步,人们发现了更多的使用SOAP的方式,而不仅仅是采用“文件”方式——基本上是使用一个SOAP信封来传送XML格式化文件。无论如何,要掌握SOAP,了解WSDL所扮演的角色是最根本的。

Web服务描述语言或WSDL
为了创建一个用于描述Web服务的XML格式化文件,Web服务描述语言(WSDL)标准提供了足够多的细节,以便能够构建出客户端代码,从而访问服务或者服务器端代码以提供服务。一个服务的WSDL文件将会为你提供以下几个方面的内容:

用于访问服务的地址信息
用于传送信息的传输协议(例如,通道数)
用于所有可使用功能的名称和接口使用方法
在所有的请求和响应中所使用的数据类型
2001年3月,W3C推出了WSDL 1.1版本用于讨论,这并不是最终确定的规范。W3C Web服务描述工作组目前正在开发该规范的2.0版本,基本上已经到了尾声。虽然,WSDL通常是用于特定的SOAP服务,但是,从理论说,它是完全可以用于特定的REST风格的GET或者POST操作的。

能够根据服务的WSDL描述来自动创建客户端和服务器端代码,支持这一功能的开发环境目前使用得很广泛,以便能够适用于Web服务器和Web服务客户端的不同程序设计语言。如果你使用Google搜索“SOAP IDE”的话,大概会出现上百万条相关信息。也有这样的工具,根据Java或C#对象来生成相应的WSDL和代码。自动生成代码也许能够使你的开发效率更高,但是离优化却是越来越远。

安全与SOAP

如果企业使用SOAP来传送有价值的信息的话,那么,安全就是最重要的问题。由OASIS组织发起,计算机行业的领导者们已经联合开发了一套标准,称为WS-Security。这个标准对基本的SOAP通信做出了改善,以便能够处理以下几个问题:

消息机密性——由于拦截HTTP消息的方式非常多,因此,在请求和响应过程中,必须能够对所有重要信息加密。很幸运,现在的加密技术非常先进,我们能够对消息内容进行加密,以保证消息不被修改。

客户和服务身份——必须能够核实SOAP请求来源的身份。

结论

在开发人员的意识里,对于Web服务的开发而言,REST和SOAP风格各有千秋。SOAP拥有更为详尽的标准化成果和开源工具。除此之外,现在,有许多集成开发环境能够在现有代码的基础上,依据接口方法自动生成SOAP。如果你需要使用WSDL来发布你的服务,或者你需要一些安全功能如消息签名和加密,那么,SOAP能够确保消息的安全性。另一方面,如果你希望使用简单接口来公布一些信息,而不需要繁琐的处理过程,那么,REST也许是最佳选择。

——END——
原文来自:http://www.diybl.com/course/3_program/java/javajs/2007918/71772.html
仅作参考

REST与SOAP的比较——REST篇

REST与SOAP的比较——REST篇

 我有这样一个推断,在计算机世界中,但凡那些让开发人员记住的重要概念,都有一个很酷的名称首字母缩写,否则的话,开发人员很快就会将其抛之脑后。比如Ajax、SOAP以及REST就证明了这一点。

REST能够在计算机领域被广泛采用,它走的道路是不同寻常的。这个术语是由Roy Fielding创造的。Fielding毕业于Irvine市加利福尼亚大学,在他的博士学位论文中第一次提出了REST这个概念。在Web方面,我们必须承认Fielding是非常精通的,他曾经帮助创建HTTP 1.0规范,该规范从1996年开始就为Web提供基本准则。他在Web标准方面非常有经验,这为他的这篇博士论文奠定了坚实的基础。

Fielding指出,使用且符合代表性状态传输(REST)设计约束的 Web 上部署的组件,可以充分利用 Web 的有用特性,万维网(World Wide Web)才能够达到最佳的工作效果。可以这样理解REST——当一个浏览器得到并且显示构成HTML页面的各个元素时,它正在获取资源的当前状态的表现形式。在Fielding的博士论文中,他列举了REST风格的设计约束,并且解释了为什么这些约束能够充分利用Web 的有用特性,使其达到最佳状态,以及这些约束的关键所在。同时,在论文中,他也包含了一些关于REST和某些目前的Web风格之间 “不符合”的讨论,以及这些Web风格是如何导致设计无法利用Web特性的。

Fielding认为,对于使用HTTP承载应用程序协议穿越防火墙,XML-RPC 和SOAP所采用的方式是“从根本上被误导的概念。”它们所采用的方式违背了设立防火墙的概念,结果是,防火墙厂商为了保护系统需要侦察出所承载的协议。由于大多数SOAP应用程序使用HTTP都是为了穿越防火墙,因此,你可以发现REST与SOAP之间的冲突是从哪里开始的。Fielding认为,如果你打算使用HTTP的话,就应该与充分利用HTTP本身的含义。

REST风格强调,通过有限的操作或者是“动词”以及一个组件之间的标准接口,也就是HTTP协议提供的借口,来提升客户与服务之间的交互。通过为每一个资源分配其自己的URL,来实现灵活性,REST可以调用包含上百个URI的资源类型的客户,其中的关键是REST能够给你无限多的“名词”。REST使用HTTP的动词——简单的良定义操作集:POST, GET, PUT,DELETE进行请求和响应,从而避免了歧义。举个例子,GET只能够简单地返回资源的表现形式,而不能够创建任何其他的内容。

在Web发展的初期,由于人们都在试验通过收集各种不同来源的元素,从而把Web应用程序融合在一起,有大量这种Web服务的不成熟探索的例子——从HTTP页面中解析信息,用于页面创建者没有计划到的用途。这种“屏幕抓取”的Web类比表明,REST风格的方法是先于那些更加复杂的Web服务而出现的。

REST是一种风格而不是一个标准

你可能会把软件的架构风格当作对上层设计模式的抽象。然而,根据Fielding所说,设计模式的堆砌并不等同于架构风格,因为模式是非常接近于特定问题的。

由于REST是超文本系统的一种风格,而不是Web服务的,因此,本文的标题“REST与SOAP之比较”就有些让人误解。然而,很多软件设计人员会将其混淆,他们在考虑如何创建Web服务时,会得出这样的结论:SOAP过于复杂,而简单的类似于REST的设计却更加适合。

REST与RPC风格之比较

远程过程调用的架构,是应用在基于XML-RPC或者 RPC风格的SOAP的Web服务中的,它却有着完全不同的风格。客户端发出命令,以使服务做出特定的操作。换句话说,RPC有动词的倾向。

REST强调资源(名词)有统一的接口以此来对它们寻址,而RPC强调过程(动词)有统一的接口来激发它们。一个基于RPC的架构,动词数量是没有限制的。REST说,我们使用四个动词——非常熟悉,HTTP标准的GET、POST、PUT以及DELETE——来进行请求和响应,REST使用资源寻址来处理其可变性。

一个简单的REST举例

假设我们希望一个Web服务暴露一部分目录,从这个目录中,用户将能够得到一些描述、图片、安装指令等等。为了得到数字“n1996-01”的描述,用户需要格式化一个GET请求,类似于下面的这个URL:

http://company.com/catalog/description/n1996-01

在处理这个请求时,“/catalog”将映射到一个服务中,之后,通过该服务对“description/n1996-01”进行解释,从而定位资源。在创建响应时,服务需要使用内容类型(Content-Type)的头文件来指定返回格式。在这种情况下,假定返回格式是HTML或者XML,客户端能够使用它来控制页面的布局。如果要得到图片,那么这个请求将对“/catalog/picture/n1996-01”进行寻址,返回的响应将是图片内容类型(Content-Type)。

REST的商业应用

最近几年,大多数Web商业企业开始对REST非常感兴趣。Google Data API(目前还在测试版本)专门使用REST规则来提供简单的协议。对服务的HTTP GET请求的响应结果是,采用Atom或者是RSS联合格式的XML数据。Google也使用Atom以及POST、PUT和DELETE操作来完成公共协议。eBay服务提供通过使用不同语言工具来访问服务,这些工具包括文档/文字风格的SOAP以及REST风格。

那么,对于XML-RPC和SOAP所具有的RPC风格而言,REST风格是否是一个具有竞争力的替代者呢?当然,我决不这样认为,在下一篇文章中,我将尽量向大家展现SOAP所向无敌的领域。
———END——
原文来自:http://www.diybl.com/course/3_program/java/javajs/2007918/71777.html
仅作参考

看到一篇误人子弟的PHP代码

看到一篇误人子弟的PHP代码

原文地址:http://hi.baidu.com/hi_bai_du_com/blog/item/fd297b89b318a8b20e24444a.html

原文:

<?
/*
#
# 数据表的结构 `images`
#

CREATE TABLE images (
picid int(3) NOT NULL auto_increment,
picdata longblob NOT NULL,
pictext varchar(100) NOT NULL default '',
PRIMARY KEY (picid)
) TYPE=MyISAM;

*/
if(trim($picfile[0])!=""){
$link=@mysql_connect("localhost","root","root");
//连接,用你的具体连接名替换root,具体连接密码替换root
if($link==false) {
echo "<script>alert('连接数据库时发生错误,请稍后再试!')</script>";
}
$res=mysql_select_db("kkk");
if($res==false){
echo "<script>alert('打开数据库时发生错误,请稍后再试!')</script>";
}
$tmpset=0;
// 存放成功加入的图片数目
for($i=0;$i<=3;$i++){
// picfile[i]存放所提交的图片信息(文件路径)
if(trim($picfile[$i])!=""){
//读取数据
$fp=fopen($picfile[$i],"r");
$picdata=fread($fp,filesize($picfile[$i]));
fclose($fp);
//加上必要的标志符号
$picdata=addslashes($picdata);
//用具体的数据表名代替images
//pictext[i]存放所提交的图片的文字说明
$qu="insert into images(picdata,pictext) values('$picdata','$pictext[$i]')";
$res=@mysql_query($qu,$link);
if($res==false){
echo "<script>alert('图片 ".$i." 提交失败!')</script>";
continue;
}
$tmpset=$tmpset+1;
}
}
echo "<script>alert('操作成功!实际入库图片数 ".$tmpset." 张')</script>";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<form action="<? echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data" name="form1">
<input type="file" name="picfile[]">文件说明<input type="text" name="pictext[]"><br/>
<input type="file" name="picfile[]">文件说明<input type="text" name="pictext[]"><br/>
<input type="file" name="picfile[]">文件说明<input type="text" name="pictext[]"><br/>
<input type="file" name="picfile[]">文件说明<input type="text" name="pictext[]"><br/>
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>
<?
/*
* 在外部用<img src="displayimg.php?picid=1">来调用数据库中的第一张图片
*/

$link=@mysql_connect("localhost","root","root");
mysql_select_db("kkk");
$qu="select picid,picdata from images where picid=$picid";
$res=@mysql_query($qu,$link);
$num=mysql_num_rows($res);
if($num==0){
print "<br/><br/><br/>";
print "<p><b>没有这张图片!</b></p>";
exit();
}
$row=@mysql_fetch_row($res);
header("Content-type:image/");
echo $row[1];
?>

——END——
仔细看看吧。。。是怎么误人子弟的。唉。
1、上传没有上传(大哥,你这是读本地文件呐,如果是这样的话,那。。。要那个enctype有啥用?)
2、变量直接全局(。。。。。。。。)
3、二进制字段是可以直接echo输出的吗??不谈别的,刚才你都addslashes了,为什么输出的时候没有stripslashes??
4、header头。。。。
5、for循环,直接就是3了。。这个居然就写死了
6、$tmpset的加法。。。都用了for了,用这个有意义吗??直接用$i不就完了?(这个就不算他的问题,算是习惯吧)
7、BLOB字段的插入。。。直接插的吗???看这里
MySQL 5 中 blob 类型字段的插入

PHP 4官方支持结束

PHP 4官方支持结束

自2000年5月22日发布正式稳定版8年之后,8月8日标志着PHP 4生命的终结,官方不再提供支持,不会再有安全补丁发布。PHP 4.4.9是PHP 4.x的最后一个版本。管理员和开发者失去了最后一个不升级到新一代版本开发环境的理由。过去几年,PHP 5提供了多种升级的途径,它的最新版本是5.2.6。但PHP 4发布8年之后,仍然有相当多的系统将不会在未来迁移到PHP 5,其中有相当的一部分可能永远也不会升级到PHP 5。
对于那些不升级到新版PHP的用户,PHP专家Stefan Esser将通过Suhosin项目继续为PHP 4.x系列提供第三方安全补丁。

节目预告:学习PHP持久化

节目预告:学习PHP持久化

对象的持久化最初是从JAVA那边提出来的,只是人家是编译型的语言,而PHP是解释性语言,在PHP4的时候已经可以持久化了,只是那时候PHP的性能还只是一般(相对于5而言,主要是指对象操作方面),如今PHP5横行于世,持久化也就在各种各样的项目中被使用。

今天再整理一下,争取明天发出来,如果太多,那就只能连载了。。

本人较懒,黑黑

PHP 5.0 中多态性的实现方案浅析

PHP 5.0 中多态性的实现方案浅析

  一、 PHP 5和多态性

本文想讨论面向对象编程中最为重要的部分之一--多态 性的设计。为了说明问题,我使用了PHP 5。在你继续阅读之前,请首先明确本文并不是完全有关于PHP的。尽管这种语言在以前的两个主要版本中在快速开发方面已经取得很大的进步,但是,在其与更 为成熟的语言如C++或者Java相匹敌之前,它对于对象的支持还要经历一段历程。

如果你是一位面向对象编程的入门者,那么本文可能不适合你,因为多态性这部分知识比较特别:一旦理解了它,你将永远不会忘记。如果你想简单了解一点对象编程和设计知识,并且当某人说"某个对象是多态的"时,还不十分清楚这是什么意思的话,那么本文正适合你。
到本文最后,你应该知道什么是多态性以及如何把它应用到面向对象的设计中,并且你会了解PHP 5中对象编程的优点与不足。

二、什么是多态性?

多态性,其来自于dictionary.com的定义是"以不同形式,阶段或者类型出现在独立的组织中或者同种组织中,而不存在根本区别。"由该定义, 我们可以认为,多态性是一种通过多种状态或阶段来描述相同对象的编程方式。其实,它的真正意义在于:实际开发中,我们只需要关注一个接口或基类的编程,而 不必担心一个对象所属于的具体类(class)。

如果你熟悉设计模式,即使只是有个初步了解,那么你也会了解这个概念。事实上,多态 性可能是基于模式设计编程中的最伟大的工具。它允许我们以一种逻辑的方式来组织相类似的对象从而实现在具体编码时不必担心对象的具体类型;而且,我们只需 要对一个所期望的接口或基类编程即可。一个应用程序越抽象,则它就显得越灵活--而多态性是对行为加以抽象的最好的方式之一。

例如, 让我们考虑一个叫Person的类。我们可以用称为David,Charles和Alejandro的类来子类化Person。Person有一个抽象方 法AcceptFeedback(),所有的子类都要实现这个方法。这意味着,任何使用基类Person的子类的代码都能调用方法 AcceptFeedback()。你不必检查该对象是一个David还是一个Alejandro,仅知道它是一个Person就够了。结果是,你的代码 只需关注"最小公分母"-Person类即可。

在这个示例中的Person类也可以被创建为一个接口。当然,与上面相比存在一些区 别,主要在于:一个接口并没有给出任何行为,而仅确定了一组规则。一个Person接口要求的是"你必须支持AddFeedback()方法",而一个 Person类可以提供一些AddFeedback()方法的缺省代码-你对之的理解可以是"如果你不选择支持AddFeedback(),那么你应该提 供一种缺省实现。"至于如何选择接口或基类则并非本文的主题;但是,一般说来,你需要通过基类来实现一个缺省的方法。如果你能够简单地勾勒出你的类所要实 现的一组期望的功能,那么你也可以使用一个接口。

三、应用多态性设计

我们将继续使用Person基类的例子,现在让我们分析一个非多态性的实现。下列示例中使用了不同类型的Person对象--这是一种非常不理想的编程方式。注意,实际的Person类被省略。目前为止,我们仅关心代码调用的问题。

<?php
$name = $_SESSION['name'];
$myPerson = Person::GetPerson($name);
switch (get_class($myPerson)){
case 'David' :
$myPerson->AddFeedback('Great Article!','Some Reader', date('Y-m-d'));
break;
case 'Charles':
$myPerson->feedback[] = array('Some Reader', 'Great Editing!');
break;
case 'Alejandro' :
$myPerson->Feedback->Append('Awesome Javascript!');
break;
default :
$myPerson->AddFeedback('Yay!');
}
?>
  这个示例展示了行为不同的对象,还有一个switch语句用于区分不同的Person类对象,从而执行其各自相应的正确操作。注意,这里针对不同条件的回馈注释是不同的。在实际应用程序开发中可能不会出现这种情形;我仅为了简单地说明类实现中存在的区别。

下面的一个示例使用了多态性。
<?php
$name = $_SESSION['name'];
$myPerson = Person::GetPerson($name);
$myPerson->AddFeedback('Great Article!', 'SomeReader', date('Y-m-d'));
?>
  注意,这里没有switch语句,而最重要的是,缺乏有关Person::GetPerson()会返回什么类型的 对象。而另一个Person::AddFeedback()是一个多态方法。行为完全是由具体类进行封装的。请记住,在此无论我们使用的是 David,Charles还是Alejandro,调用代码从不必了解具体类的功能,而仅知道基类就可以了。

尽管我的示例并不完 美,但是,从调用代码的角度,它已经展示了多态性的基本用法。现在我们需要分析这些类的内部实现。从一个基类进行派生的一个最伟大的地方在于,该派生类能 够存取父类的行为,这种情况常常是缺省的实现,但是也可能出现在类继承链中用于创建更为复杂的行为。下面是这种情况的一个简单展示。
<?php
class Person{
function AddFeedback($comment, $sender, $date){
//把回馈添加到DB
}
}
class David extends Person{
function AddFeedback($comment, $sender){
parent::AddFeedback($comment, $sender,
date('Y-m-d'));
}
}
?>
  在此,David类中的AddFeedback方法实现中首先调用了Person::AddFeedback方法。你可能注意到,它模仿了C++,Java或C#中的方法重载。请记住,这仅是一个简单化的示例,并且你编写的实际代码完全依赖于你的实际工程。
四、PHP 5中的迟绑定

依我的看法,迟绑定正是使得Java和C#如此引人注目的重要原因。它们允许基类方法用"this"或$this来调用方法(即使它们不存在于基类中或调用一个基类中的方法,它有可能为继承类中的另一个版本所代替)。你可以认为如下的实现在PHP中是允许的:
<?php
class Person{
function AddFeedback($messageArray) {
$this->ParseFeedback($messageArray);
//写向数据库
}
}
class David extends Person{
function ParseFeedback($messageArray){
// 进行一些分析
}
}
?>
  记住,在Person类中并没有ParseFeedback。现在,假定你拥有这一部分实现代码(为了本例说明问题起见),那么这会导致$myPerson成为一个David对象:
<?php
$myPerson = Person::GetPerson($name);
$myPerson->AddFeedback($messageArray);
?>
  出现分析错误!大致错误信息为,方法ParseFeedback并不存在或者一些类似的信息。关于PHP 5中的迟绑定我们就讨论这些!下面我们再归纳一下迟绑定的概念。

迟绑定意味着,方法调用在最后时刻才绑定到目标对象。这意味着,当该方法被运行时刻调用时,那些对象已经有了一种具体类型。在我们上面的示例中,你调用 了David::AddFeedback(),而既然David::AddFeedback()中的$this引用一个David对象,那么你可以逻辑地 假定ParseFeedback()方法是存在的--但事实上它并不存在,因为AddFeedback()是在Person中定义的,并且从Person 类中调用ParseFeedback()。
不幸的是,没有简单的方法来消除PHP 5中的这种行为。这意味着,当你想创建一个灵活的多态类层次时你可能有点无能为力。

我必须指出,我选择PHP 5作为本文的表达语言仅仅是因为:这种语言并没有实现对象概念的完美抽象!因为PHP 5还处于其测试版本运行期,所以这是可以谅解的。另外,既然该语言中加入了抽象类和接口,迟绑定也应该被实现。

五、小结

至此,你应该基本了解什么是多态性以及为什么PHP 5在实现多态性方面并不完美。一般说来,你应该知道如何用一个多态性对象模型来封装有条件的行为。当然,这样会提高你的对象的灵活性,并且意味着更少的代 码实现。另外,通过封装满足一定条件的行为(具体要依赖于对象的状态),你还提高了代码的清晰程度。

-------------------------------------
注:现在大多数的程序都已经采用了这种特性,在框架中运用的犹为明显,虽然文章有点老了,但还是值得一看。
象最后一句说的,这提高了代码的清晰程度

一些看似简单却容易被忽视的小技巧

一些看似简单却容易被忽视的小技巧

在工作中我总是会发现有些人的程序里有些不妨碍程序正常执行的小问题,并且很多人都常常愿意这样写,下面我列举一下

1.php属于弱语言,所以在使用一个变量的时候,不需要为其指定变量类型和初始化值,但是我强烈建议在使用一个变量前,先为其初始化一个默认值,这样既安全又规范

2.
if (条件表达式1 && 条件表达式2)
//do something
else
//do something
?>

当进行与运算操作的时候,最好把最可能返回"False"的表达式放在操作的前面,这样当if条件遇到false后,就不在执行false以后的运算了,这样加快程序的执行速度,但是要注意一点的是false以后的条件表达式如果是个赋值的表达式,例如:


$a = 1;
$b = 0;
if (($a > 1) && ($b = 2))
?>

这段程序在$a > 1这个地方就执行完了,$b = 2的赋值操作将不再执行,结果$b的值还是0.


3.在使用mysql数据库的时候,执行"select count"操作的时候,尽量使用count(*)而不是count(一个字段),count(*)会直接使用索引文件进行统计(inndb类型的表除外)而不是去遍历整个数据表

4.在使用group by的时候,如果没有必要对返回结果集合进行排序,建议加上"order by null",这样会减少一步排序的操作

5.为table建立复合索引的时候,比如"name-city-age"这个索引,这个索引是由表中的字段name,city,age组成的,虽然我们 只为这张表建立了一个索引,但其实...嘿嘿嘿...这是三个索引,恩,哪三个索引呢...name,name-city,name-city-age这 三个索引,请注意,复合索引遵循的是最左原则,所以name-age,city-age将不会使用索引...

6.在建索引的时候,如果能保证这个(复合)索引的字段(组合)的值肯定是唯一值,那么就把这个(复合)索引建成唯一索引...

取自abetterday的博客:http://www.phpwap.cn/?action=articleContent&articleId=153

利用imageMagicK制作有背景色的缩略图

原文如下:附本人翻译(翻译水平其差,可以忽略直接看英文)

I know, it's been a while since I last blogged. This is because a lot of things are happening in my personal life. I recently relocated to London from Finland and started a new job. Things are quite busy but I will try to post an example now and then. In the meanwhile I would like to hear about sites using Imagick, so if your project is not super secret please post an url and maybe a small explanation what you're doing with Imagick on the site. This is purely for my personal interest.

Anyway, to the point. Today's example originates from a question asked by a user. How do I thumbnail the image inside given dimensions proportionally and fill the "blank" areas with a color? Well, the answer is here :)

The code is for Imagick 2.1.0 but adapting to older versions should not be hard.

翻译如下:

我知道现在离我的博客更新有一段时间了,这主要是因为最近发生了很多事。最近我找了份新工作,使我从芬兰搬到了伦敦,工作也非常忙,所以我在这里仅仅只发一个示例。同时我很高兴听到很多网站使用了imagick,我也希望如果您的项目不是很保密的话,是否能够发个链接及少量的注释以说明您的站点是如何使用Imagek的。顺便说一声,这完全是我个人的兴趣。

OK,上重头菜。今天的例子起源于一个用户的问题,那就是如果在为一张图片按比例做缩略图的时候,怎么为留空的地方用其他颜色填充。这个例子就是我的回复。

代码是FOR ImagicK 2.1.0版本,当然要改成以前的老版本代码也不是件难事。

下面就是代码了:

<?php
/* Define width and height of the thumbnail */
/* 定义缩略图的长宽*/
$width = 100;
$height = 100;

/* Instanciate and read the image in */
/*创建一个对象,同时读回源图*/
$im = new Imagick( "test.png" );
/* Fit the image into $width x $height box
The third parameter fits the image into a "bounding box" */
/*按照比例进行缩放*/
$im->thumbnailImage( $width, $height, true );
/* 按照缩略图大小创建一个有颜色的图片 */
$canvas = new Imagick();
$canvas->newImage( $width, $height, 'pink', 'png' );
/* 取得缩图的实际大小 */
$geometry = $im->getImageGeometry();
/* 计算高度 */
$x = ( $width - $geometry['width'] ) / 2;
$y = ( $height - $geometry['height'] ) / 2;
/* 合并图片 */
$canvas->compositeImage( $im, imagick::COMPOSITE_OVER, $x, $y );
/* 输出图片*/
header( "Content-Type: image/png" );
echo $canvas;
?>

膘叔,上图片

源图:

b97200df758a3c022937df8fb60d66dc

缩图:

086d2bb302b8971e878da2f4a1e50c41

PHP5.30的更新列表

PHP5.30的更新列表

啥也不说了。自己看列表吧。。原来,更新了这么多啊。。。。。。现在还是alpha,等到了stable,那我应该不应该更新呢》》》

PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 200?, PHP 5.3.0 Alpha 2
- Removed shebang line check from CGI sapi (it is checked by scanner) (Dmitry)

- Fixed bug #45696 (Not all DateTime methods allow method chaining). (Derick)
- Fixed bug #45545 (DateInterval has a limitation of 4 chars for ISO
durations). (Derick)
- Fixed bug #45406 (session.serialize_handler declared by shared extension
fails). (Kalle, oleg dot grenrus at dynamoid dot com)
- Fixed bug #44100 (Inconsistent handling of static array declarations with
duplicate keys). (Dmitry)
- Fixed bug #43008 (php://filter uris ignore url encoded filternames and can't
handle slashes). (Arnaud)

01 Aug 2008, PHP 5.3.0 Alpha 1
- Upgraded bundled PCRE to version 7.7. (Nuno)
- Upgraded bundled PDO sqlite to version 3.5.9. (Scott)

- Moved extensions to PECL (Pierre):
. ext/fdf
. ext/ncurses
. ext/sybase (not maintained anymore, sybase_ct has to be used instead)

- Removed the experimental RPL (master/slave) functions from mysqli. (Andrey)
- Removed zend.ze1_compatibility_mode. (Dmitry)
- Deprecated ticks support. (Felipe)

- Changed PCRE, Reflection and SPL extensions to be always enabled. (Marcus)
- Changed md5() to use improved implementation. (Solar Designer, Dmitry)
- Changed HTTP stream wrapper to accept any code between and including
200 to 399 as successful. (Mike, Noah Fontes)

- Improved PHP syntax and semantics:
. Added lambda functions and closures. (Christian Seiler, Dmitry)
. Added "jump label" operator (limited "goto"). (Dmitry, Sara)
. Added NOWDOC syntax. (Gwynne Raskind, Stas, Dmitry)
. Added HEREDOC syntax with double quotes. (Lars Strojny, Felipe)
. Added support for using static HEREDOCs to initialize static variables and
class members or constants. (Matt)
. Improved syntax highlighting and consistency for variables in double-quoted
strings and literal text in HEREDOCs and backticks. (Matt)
. Added "?:" operator. (Marcus)
. Added support for namespaces. (Dmitry, Stas, Gregory)
. Added support for Late Static Binding. (Dmitry, Etienne Kneuss)
. Added support for __callStatic() magic method. (Sara)
. Added forward_static_call(_array) to complete LSB. (Mike Lively)
. Added support for dynamic access of static members using $foo::myFunc().
(Etienne Kneuss)
. Improved checks for callbacks. (Marcus)
. Added __DIR__ constant. (Lars Strojny)
. Added PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION,
PHP_EXTRA_VERSION, PHP_VERSION_ID, PHP_ZTS and PHP_DEBUG constants.
(Pierre)
. Added new error modes E_USER_DEPRECATED and E_DEPRECATED.
E_DEPRECATED is used to inform about stuff being scheduled for removal
in future PHP versions. (Lars Strojny, Felipe, Marcus)
. Added "request_order" INI variable to control specifically $_REQUEST
behavior. (Stas)
. Added support for exception linking. (Marcus)
. Added ability to handle exceptions in destructors. (Marcus)

- Improved PHP runtime speed and memory usage:
. Substitute persistent constants by their values at compile time. (Matt)
. Optimized ZEND_SIGNED_MULTIPLY_LONG(). (Matt)
. Removed direct executor recursion. (Dmitry)
. Use fastcall calling convention in executor on x86. (Dmitry)
. Use IS_CV for direct access to $this variable. (Dmitry)
. Use ZEND_FREE() opcode instead of ZEND_SWITCH_FREE(IS_TMP_VAR). (Dmitry)
. Lazy EG(active_symbol_table) initialization. (Dmitry)
. Optimized ZEND_RETURN opcode to not allocate and copy return value if it is
not used. (Dmitry)
. Replaced all flex based scanners with re2c based scanners.
(Marcus, Nuno, Scott)
. Added garbage collector. (David Wang, Dmitry).
. Improved PHP binary size and startup speed with GCC4 visibility control.
(Nuno)
. Improved engine stack implementation for better performance and stability.
(Dmitry)
. Improved memory usage by moving constants to read only memory.
(Dmitry, Pierre)
. Changed exception handling. Now each op_array doesn't contain
ZEND_HANDLE_EXCEPTION opcode in the end. (Dmitry)
. Optimized require_once() and include_once() by eliminating fopen(3) on
second usage. (Dmitry)
. Optimized ZEND_FETCH_CLASS + ZEND_ADD_INTERFACE into single
ZEND_ADD_INTERFACE opcode. (Dmitry)
. Optimized string searching for a single character.
(Michal Dziemianko, Scott)
. Optimized interpolated strings to use one less opcode. (Matt)

- Improved php.ini handling: (Jani)
. Added ".htaccess" style user-defined php.ini files support for CGI/FastCGI.
. Added support for special [PATH=/opt/httpd/www.example.com/] and
[HOST=www.example.com] sections. Directives set in these sections can
not be overridden by user-defined ini-files or during runtime.
. Added better error reporting for php.ini syntax errors.
. Allowed using full path to load modules using "extension" directive.
. Allowed "ini-variables" to be used almost everywhere ini php.ini files.
. Allowed using alphanumeric/variable indexes in "array" ini options.
. Added 3rd optional parameter to parse_ini_file() to specify the scanning
mode of INI_SCANNER_NORMAL or INI_SCANNER_RAW. In raw mode option values
and section values are treated as-is.
. Fixed get_cfg_var() to be able to return "array" ini options.
. Added optional parameter to ini_get_all() to only retrieve the current
value. (Hannes)

- Improved and cleaned CGI code:
. FastCGI is now always enabled and can not be disabled.
See sapi/cgi/CHANGES for more details. (Dmitry)
. Added CGI SAPI -T option which can be used to measure execution
time of script repeated several times. (Dmitry)

- Improved streams:
. Fixed confusing error message on failure when no errors are logged. (Greg)
. Added stream_supports_lock() function. (Benjamin Schulz)
. Added "ignore_errors" option to http fopen wrapper. (David Zulke, Sara)
. Added context parameter for copy() function. (Sara)
. Added "glob://" stream wrapper. (Marcus)
. Added "params" as optional parameter for stream_context_create(). (Sara)
. Added ability to use stream wrappers in include_path. (Gregory, Dmitry)

- Improved hash extension:
. Changed mhash to be a wrapper layer around the hash extension. (Scott)
. Added hash_copy() function. (Tony)
. Added sha224 hash algorithm to the hash extension. (Scott)

- Improved mbstring extension:
. Added "mbstring.http_output_conv_mimetypes" INI directive that allows
common non-text types such as "application/xhtml+xml" to be converted
by mb_output_handler(). (Moriyoshi)

- Improved OCI8 extension (Chris Jones/Oracle Corp.):
. Added Database Resident Connection Pooling (DRCP) and Fast
Application Notification (FAN) support.
. Added support for Oracle External Authentication (not supported
on Windows).
. Improve persistent connection handling of restarted DBs.
. Added SQLT_AFC (aka CHAR datatype) support to oci_bind_by_name.
. Fixed bug #41069 (Seg fault with query over DB link).
. Fixed define of SQLT_BDOUBLE and SQLT_BFLOAT constants with Oracle
10g ORACLE_HOME builds.
. Changed default value of oci8.default_prefetch from 10 to 100.
. Fixed PECL bug #12431 (OCI8 ping functionality is broken).
. Allow building (e.g from PECL) the PHP 5.3-based OCI8 code with
PHP 4.3.9 onwards.

- Improved OpenSSL extension: (Dmitry)
. Added support for OpenSSL digest and cipher functions.
. Added access to internal values of DSA, RSA and DH keys.

- Improved pcntl extension: (Arnaud)
. Added pcntl_signal_dispatch().
. Added pcntl_sigprocmask().
. Added pcntl_sigwaitinfo().
. Added pcntl_sigtimedwait().

- Improved SOAP extension:
. Added support for element names in context of XMLShema's <any>. (Dmitry)
. Added ability to use Traversable objects instead of plain arrays.
(Joshua Reese, Dmitry)
. Fixed possible crash bug caused by an uninitialized value. (Zdash Urf)

- Improved SPL extension:
. Added SPL to list of standard extensions that cannot be disabled. (Marcus)
. Added ability to store associative information with objects in
SplObjectStorage. (Marcus)
. Added ArrayAccess support to SplObjectStorage. (Marcus)
. Added SplDoublyLinkedList, SplStack, SplQueue classes. (Etienne)
. Added FilesystemIterator. (Marcus)
. Added GlobIterator. (Marcus)
. Added SplHeap, SplMinHeap, SplMaxHeap, SplPriorityQueue classes. (Etienne)
. Added new parameter $prepend to spl_autoload_register(). (Etienne)
. Added FixedArray. (Etienne, Tony)
. Added delaying exceptions in SPL's autoload mechanism. (Marcus)
. Added RecursiveTreeIterator. (Arnaud, Marcus)
. Added MultipleIterator. (Arnaud, Marcus, Johannes)

- Improved Zend Engine:
. Added "compact" handler for Zend MM storage. (Dmitry)
. Added "+" and "*" specifiers to zend_parse_parameters(). (Andrei)
. Added concept of "delayed early binding" that allows opcode caches to
perform class declaration (early and/or run-time binding) in exactly
the same order as vanilla PHP. (Dmitry)

- Improved crypt() function: (Pierre)
. Added Blowfish and extended DES support. (Using Blowfish implementation
from Solar Designer).
. Made crypt features portable by providing our own implementations
for crypt_r and the algorithms which are used when OS does not provide
them. PHP implementations are always used for Windows builds.

- Added new extensions:
. Added fileinfo extension as replacement for mime_magic extension. (Derick)
. Added intl extension for Internationalization. (Ed B., Vladimir I.,
Dmitry L., Stanislav M., Vadim S., Kirti V.)
. Added mysqlnd extension as replacement for libmysql for ext/mysql, mysqli
and PDO_mysql. (Andrey, Johannes, Ulf)
. Added phar extension for handling PHP Archives. (Greg, Marcus, Steph)
. Added SQLite3 extension. (Scott)

- Added new date/time functionality: (Derick)
. date_parse_from_format(): Parse date/time strings according to a format.
. date_create_from_format()/DateTime::createFromFormat(): Create a date/time
object by parsing a date/time string according to a given format.
. date_get_last_errors()/DateTime::getLastErrors(): Return a list of warnings
and errors that were found while parsing a date/time string through:
. strtotime() / new DateTime
. date_create_from_format() / DateTime::createFromFormat()
. date_parse_from_format().
. support for abbreviation and offset based timezone specifiers for
DateTime::getOffset() and DateTime::getName().
. support for selectively listing timezone identifiers by continent or
country code through timezone_identifiers_list() /
DateTimezone::listIdentifiers().
. timezone_location_get() / DateTimezone::getLocation() for retrieving
location information from timezones.
. date_timestamp_set() / DateTime::setTimestamp() to set a Unix timestamp
without invoking the date parser. (Scott, Derick)
. date_timestamp_get() / DateTime::getTimestamp() to retrieve the Unix
timestamp belonging to a date object.
. two optional parameters to timezone_transitions_get() /
DateTimeZone::getTranstions() to limit the range of transitions being
returned.
. support for "first/last day of <month>" style texts.
. support for date/time strings returned by MS SQL.
. support for serialization and unserialization of DateTime objects.
. support for diffing date/times through date_diff() / DateTime::diff().
. support for adding/subtracting weekdays with strtotime() and
DateTime::modify().
. DateInterval class to represent the difference between two date/times.
. support for parsing ISO intervals for use with DateInterval.
. date_add() / DateTime::add(), date_sub() / DateTime::sub() for applying an
interval to an existing date/time.
. proper support for "this week", "previous week"/"last week" and "next week"
phrases so that they actually mean the week and not a seven day period
around the current day.
. support for "<xth> <weekday of" and "last <weekday> of" phrases to be used
with months - like in "last saturday of februari 2008".
. DatePeriod class which supports iterating over a DateTime object applying
DateInterval on each iteration, up to an end date or limited by maximum
number of occurences.

- Added array_replace() and array_replace_recursive() functions. (Matt)
- Added ReflectionProperty::setAccessible() method that allows non-public
property's values to be read through ::getValue(). (Derick)
- Added msg_queue_exists() function to sysvmsg extension. (Benjamin Schulz)
- Added Firebird specific attributes that can be set via PDO::setAttribute()
to control formatting of date/timestamp columns: PDO::FB_ATTR_DATE_FORMAT,
PDO::FB_ATTR_TIME_FORMAT and PDO::FB_ATTR_TIMESTAMP_FORMAT. (Lars W)
- Added gmp_testbit() function. (Stas)
- Added icon format support to getimagesize(). (Scott)
- Added LDAP_OPT_NETWORK_TIMEOUT option for ldap_set_option() to allow
setting network timeout (FR #42837). (Jani)
- Added optional escape character parameter to fgetcsv(). (David Soria Parra)
- Added an optional parameter to strstr() and stristr() for retrieval of either
the part of haystack before or after first occurrence of needle.
(Johannes, Felipe)
- Added xsl->setProfiling() for profiling stylesheets. (Christian)
- Added long-option feature to getopt() and made getopt() available also on
win32 systems by adding a common getopt implementation into core.
(David Soria Parra, Jani)
- Added support for optional values, and = as separator, in getopt(). (Hannes)
- Added lcfirst() function. (David C)
- Added PREG_BAD_UTF8_OFFSET_ERROR constant. (Nuno)
- Added native support for asinh(), acosh(), atanh(), log1p() and expm1().
(Kalle)
- Added inet_pton() and inet_ntop() also for Windows platforms. (Kalle)
- Added mcrypt_create_iv() also for Windows platforms. (Pierre)

- Fixed html_entity_decode() incorrectly converting numeric html entities
to different characters with cp1251 and cp866. (Scott)
- Fixed an issue in date() where a : was printed for the O modifier after a P
modifier was used. (Derick)
- Fixed exec() on Windows to not eat the first and last double quotes. (Scott)

- Fixed PECL bug #12794 (PDOStatement->nextRowset() doesn�t work). (Johannes)
- Fixed PECL bug #12401 (Add support for ATTR_FETCH_TABLE_NAMES). (Johannes)

- Fixed bug #45622 (isset($arrayObject->p) misbehaves with ArrayObject::
ARRAY_AS_PROPS set). (robin_fernandes at uk dot ibm dot com, Arnaud)
- Fixed bug #45614 (ArrayIterator::current(), ::key() can show 1st private
prop of wrapped object). (robin_fernandes at uk dot ibm dot com, Arnaud)
- Fixed bug #45571 (ReflectionClass::export() shows superclasses' private
static methods). (robin_fernandes at uk dot ibm dot com)
- Fixed bug #45540 (stream_context_create creates bad http request). (Arnaud)
- Fixed bug #45430 (windows implementation of crypt is not thread safe).
(Pierre)
- Fixed bug #45345 (SPLFileInfo::getPathInfo() returning dir info instead of
file info). (Etienne)
- Fixed bug #45179 (--with-mysql-sock fails to compile & work). (Andrey)
- Fixed bug #45038 (Crash when using DateTimeZone object returned by
Date::getTimezone). (Joe Orton, Derick)
- Fixed bug #44769 (declaring private magic methods should throw error).
(Felipe)
- Fixed bug #44913 (Segfault when using return in combination with nested loops
and continue 2). (Dmitry)
- Fixed bug #44899 (__isset usage changes behavior of empty()). (Etienne)
- Fixed bug #44897 (failed to prepare statement). (Andrey)
- Fixed bug #44849 (imagecolorclosesthwb() is not available on Windows).
(Kalle)
- Fixed bug #44805 (rename() function is not portable to Windows). (Pierre)
- Fixed bug #44779 (filter returns NULL in CLI when it shouldn't). (Arnaud)
- Fixed bug #44742 (timezone_offset_get() causes segmentation faults). (Derick)
- Fixed bug #44660 (Indexed and reference assignment to propery of non-object
don't trigger warning). (Dmitry)
- Fixed bug #44648 (Attribute names not checked for wellformedness). (Rob)
- Fixed bug #44414 (Incomplete reporting about abstract methods). (Dmitry)
- Fixed bug #44390 (mysqli_bind_param/bind_result and Object member variables).
(Andrey)
- Fixed bug #44352 (mysqli_connect_error() false negative for host errors).
(Andrey)
- Fixed bug #44336 (Improve pcre UTF-8 string matching performance).
(frode at coretrek dot com, Nuno)
- Fixed bug #44301 (Segfault when an exception is thrown on persistent
connections). (Martin Jansen)
- Fixed bug #44257 (timelib_tz_lookup_table must use float for gmtoffset).
(Derick, iuri dot fiedoruk at hp dot com).
- Fixed bug #44214 (Crash using preg_replace_callback() and global variable).
(Nuno, Scott)
- Fixed bug #44034 (FILE_IGNORE_NEW_LINES in file() does not work as expected
when lines end in \r\n). (Ilia)
- Fixed bug #43960 (strtotime() returns timestamp in the future when given a
bogus string). (Derick)
- Fixed bug #43832 (mysqli_get_charset() doesn't expose charset comment).
(Andrey)
- Fixed bug #43808 (date_create never fails (even when it should)). (Derick)
- Fixed bug #43527 (DateTime created from a timestamp reports environment
timezone). (Derick)
- Fixed bug #43452 (strings containing a weekday, or a number plus weekday
misbehaved if the current day-of-week was same as the one in the phrase).
(Derick)
- Fixed bug #43426 (crash on nested call_user_func() calls). (Dmitry)
- Fixed bug #43323 (Wrong count abstract methods). (Felipe, Dmitry)
- Fixed bug #43261 (Use ^ as the escape with escapeshellcmd() on Windows).
(Scott)
- Fixed bug #43075 (Support 2007-11-01T24:00:00+00:00). (Derick)
- Fixed bug #43003 (Invalid timezone reported for DateTime objects constructed
using a timestamp). (Derick)
- Fixed bug #43143 (Warning about empty IV with MCRYPT_MODE_ECB). (Derick)
- Fixed bug #43136 (possible crash on script execution timeout.
The EG(function_state_ptr) is completely removed,
EG(current_execute_data)->function_state must be used instead). (Dmitry)
- Fixed bug #42952 (soap cache file is created with insecure permissions).
(Dmitry)
- Fixed bug #42868 (Floats cast to integer produce unpredictable results).
(Zoe Slattery)
- Fixed bug #42848 (Status: header incorrect under FastCGI). (Dmitry)
- Fixed bug #42773 (WSDL error causes HTTP 500 Response). (Dmitry)
- Fixed bug #42737 (preg_split('//u') triggers a E_NOTICE with newlines).
(Nuno)
- Fixed bug #42736 (xmlrpc_server_call_method() crashes). (Tony)
- Fixed bug #42663 (gzinflate() try to allocate all memory with truncated
data). (Arnaud)
- Fixed bug #42657 (ini_get() returns incorrect value when default is NULL).
(Jani, Scott)
- Fixed bug #42637 (SoapFault : Only http and https are allowed). (Bill Moran)
- Fixed bug #42548 (mysqli PROCEDURE calls can't return result sets). (Hartmut)
- Fixed bug #42509 (gmp leaks memory when gmp_init() not used). (Stas)
- Fixed bug #42499 (PDO_MYSQL: multi-statement execution via PDO::exec() makes
connection unusable). (Johannes)
- Fixed bug #42443 (PDO SQLite driver binds integers and booleans as strings).
(Scott)
- Fixed bug #42284 (duplicate of #39700). (Lars W)
- Fixed bug #42203 (Clear SQLite result sets before closing database). (Scott)
- Fixed bug #42190 (Constructing DateTime with TimeZone Indicator invalidates
DateTimeZone). (Derick)
- Fixed bug #42069 (parse_ini_file() allows using some non-alpha numeric
characters). (Jani)
- Fixed bug #41997 (pdo_mysql: stored procedure call returning single rowset
blocks future queries). (Johannes)
- Fixed bug #41996 (Problem accessing Oracle ROWID). (Martin Jansen)
- Fixed bug #41599 (setTime() fails after modify() is used). (Derick)
- Fixed bug #41522 (PDO firebird driver returns null if it fails to connect).
(Lars W)
- Fixed bug #41135 (PDO SQLite driver binds blobs as strings,
use sqlite3_bind_blob() to stop errors with null bytes). (Scott)
- Fixed bug #39822 (new PDO() doesn't work with firebird). (Lars W)
- Fixed bug #39700 (NUMERIC error when result precision are 7,8 or 12-14 ).
(Lars W)
- Fixed bug #39457 (Multiple invoked OO connections never close). (Andrey)
- Fixed bug #39397 (invalid statement handle in Unknown on line 0). (Lars W)
- Fixed bug #39346 (Unsetting a static variable inside a destructor causes
segfault later on). (Dmitry)
- Fixed bug #39127 (Old-style constructor fallbacks produce strange results).
(Tony)
- Fixed bug #39056 (Interbase NUMERIC data type error). (Lars W)
- Fixed bug #39018 (Error control operator '@' fails to suppress "Uninitialized
string offset"). (Felipe)
- Fixed bug #38468 (Unexpected creation of cycle). (Dmitry)
- Fixed bug #37964 (Reflection shows private methods of parent class).
(Felipe, Marcus)
- Fixed bug #37911 (preg_replace_callback() ignores named groups). (Nuno)
- Fixed bug #37076 (SimpleXML ignores .=). (Felipe, Marcus)
- Fixed bug #36128 (Interbase PDO - timestamp columns return NULL). (Lars W)
- Fixed bug #35386 (firebird: first row is null). (Lars W)
- Fixed bug #35163 (Array elements can lose references). (Dmitry)
- Fixed bug #32330 (session_destroy, "Failed to initialize storage module",
custom session handler). (Gwynne)
- Fixed bug #32143 (ibase_query() causing IBserver 7 crash with NULL param as
link-id). (Lars W)
- Fixed bug #30907 (ibase_query() crashes (same bug as #32143). (Lars W)
- Fixed bug #30690 (Resource handle from ibase_execute becomes invalid after
return). (Lars W)
- Fixed bug #29044 (compact() does not have infinite recursion protection).
(Tony)
- Fixed bug #27372 (parse error loading browscap.ini at apache startup).
(Jani)