1.2 PHP发展简史
A Brief History of PHP
在1994年Rasmus Lerdorf第一个设计出了PHP,但是今天人们使用的PHP和最初的版本有很大的不同。要知道PHP如何变成今天这个样子,就必须知道PHP的发展历史。以下是Rasmus讲述的故事。
1.2.1 PHP的发展
The Evolution of PHP
以下是1995年6月我在Usener新闻组comp.infosystems.www.authoring.cgi上所发布的PHP 1.0公告:
From: rasmus@io.org (Rasmus Lerdorf)
Subject: Announce: Personal Home Page Tools (PHP Tools)
Date: 1995/06/08
Message-ID: <3r7pgp$aa1@ionews.io.org>#1/1
organization: none
newsgroups: comp.infosystems.www.authoring.cgi
Announcing the Personal Home Page Tools (PHP Tools) version 1.0.
These tools are a set of small tight cgi binaries written in C.
They perform a number of functions including:
. Logging accesses to your pages in your own private log files
. Real-time viewing of log information
. Providing a nice interface to this log information
. Displaying last access information right on your pages
. Full daily and total access counters
. Banning access to users based on their domain
. Password protecting pages based on users' domains
. Tracking accesses ** based on users' e-mail addresses **
. Tracking referring URL's - HTTP_REFERER support
. Performing server-side includes without needing server support for it
. Ability to not log accesses from certain domains (ie. your own)
. Easily create and display forms
. Ability to use form information in following documents
Here is what you don't need to use these tools:
. You do not need root access - install in your ~/public_html dir
. You do not need server-side includes enabled in your server
. You do not need access to Perl or Tcl or any other script interpreter
. You do not need access to the httpd log files
The only requirement for these tools to work is that you have
the ability to execute your own cgi programs. Ask your system
administrator if you are not sure what this means.
The tools also allow you to implement a guestbook or any other
form that needs to write information and display it to users
later in about 2 minutes.
The tools are in the public domain distributed under the GNU
Public License. Yes, that means they are free!
For a complete demonstration of these tools, point your browser
at: http://www.io.org/~rasmus
--
Rasmus Lerdorf
rasmus@io.org
http://www.io.org/~rasmus
需要注意的是,以上消息里出现的URL和E-mail地址早已不复存在了。这个声明的内容反映了当时人们所关心的东西,例如,需要密码保护的页面,易于创建的表单,和在子页面存取表单数据。这个声明也说明了PHP最初定位于一个框架,是一些有用的工具的集合。
这份声明仅谈到了伴随PHP的工具,但后来的目标是创建一个易于扩展PHP和增加更多工具的框架。这些插件的业务逻辑是使用C语言来写的,调用各种C语言的函数来从HTML中取出标签。创建一个脚本语言从来不是我的计划。
那么,后来发生了什么呢?
我开始着手于多伦多大学的一个大项目,它需要一个工具来从不同的地方取得数据,并且展现在一个漂亮的基于Web的管理界面上。当然,我确定PHP可以完美地完成这个任务,但是由于性能的原因,PHP 1的各种小工具最好能整合到一起并且完整地集成到Web服务器中。
起初,我做了一些粗糙的东西作为NCSA(国家超级计算应用中心)Web服务器的补丁,使服务器支持PHP的核心功能。这种方法的问题是,用户不得不用此特定的粗糙版本来
替换Web服务器软件。幸运的是,在此前后Apache开始增加功能,并且Apache API使得它更加容易增加功能到服务器(如PHP)。
大约在一年后,许多工作都已完成而且关注的焦点也发生了变化。下面是1996年4月我发布的PHP版本2(PHP/FI)的声明。
From: rasmus@madhaus.utcs.utoronto.ca (Rasmus Lerdorf)
Subject: ANNOUNCE: PHP/FI Server-side HTML-Embedded Scripting Language
Date: 1996/04/16
Newsgroups: comp.infosystems.www.authoring.cgi
PHP/FI is a server-side HTML embedded scripting language. It has built-in
access logging and access restriction features and also support for
embedded SQL queries to mSQL and/or Postgres95 backend databases.
It is most likely the fastest and simplest tool available for creating
database-enabled web sites.
It will work with any UNIX-based web server on every UNIX flavour out
there. The package is completely free of charge for all uses including
commercial.
Feature List:
. Access Logging
Log every hit to your pages in either a dbm or an mSQL database.
Having hit information in a database format makes later analysis easier.
. Access Restriction
Password protect your pages, or restrict access based on the refering URL
plus many other options.
. mSQL Support
Embed mSQL queries right in your HTML source files
. Postgres95 Support
Embed Postgres95 queries right in your HTML source files
. DBM Support
DB,DBM,NDBM and GDBM are all supported
. RFC-1867 File Upload Support
Create file upload forms
. Variables, Arrays, Associative Arrays
. User-Defined Functions with static variables + recursion
. Conditionals and While loops
Writing conditional dynamic web pages could not be easier than with
the PHP/FI conditionals and looping support
. Extended Regular Expressions
Powerful string manipulation support through full regexp support
. Raw HTTP Header Control
Lets you send customized HTTP headers to the browser for advanced
features such as cookies.
. Dynamic GIF Image Creation
Thomas Boutell's GD library is supported through an easy-to-use set of
tags.
It can be downloaded from the File Archive at: <URL:http://www.vex.net/php>
--
Rasmus Lerdorf
rasmus@vex.net
这是术语“脚本语言(scripting language)”第一次被使用。PHP 1 中的过分简单的标签置换(tag-replacement)功能被替换成一个可以处理更复杂的嵌入性标签语言的解析器。用今天的标准来看,标签语言并不是特别的复杂,但它和PHP1相比当然是复杂的。
这种改变的主要原因是:很少有PHP 1用户真正有兴趣使用基于C语言的框架来创建附加的组件。大多数用户更感兴趣的是可以在Web页面上直接嵌入逻辑来创建条件性的HTML、自定义标签和其他特性。PHP 1的用户要求有能力增加跟踪点击的页脚或有条件地发送各种HTML块。这导致了if标签的创建。一旦使用了if,也就必须使用else。从那时开始,无论你是否愿意,最后都要完成一个完整的脚本语言。
到1997年中,PHP第二版有了相当大的发展,并且吸引了大量的用户,但是底层解析引擎的稳定性仍然有一些问题。这个项目仍然主要是靠一个人的努力,和一点点来自其他人的帮助。这时,Tel Aviv公司的Zeev Suraski 和 Andi Gutmans 自愿重写了底层的解析引擎,并且我们赞成将它们作为PHP 第3版的基础。其他人也自愿为PHP的其他部分工作,PHP项目从一个人的项目转变成一个有很多开发者的真正的世界性开源项目。
下面是在1998年6月PHP3.0的声明。
June 6, 1998 -- The PHP Development Team announced the release of PHP 3.0,
the latest release of the server-side scripting solution already in use on
over 70,000 World Wide Web sites.
This all-new version of the popular scripting language includes support
for all major operating systems (Windows 95/NT, most versions of Unix,
and Macintosh) and web servers (including Apache, Netscape servers,
WebSite Pro, and Microsoft Internet Information Server).
PHP 3.0 also supports a wide range of databases, including Oracle, Sybase, Solid,
MySQ, mSQL, and PostgreSQL, as well as ODBC data sources.
New features include persistent database connections, support for the
SNMP and IMAP protocols, and a revamped C API for extending the language
with new features.
"PHP is a very programmer-friendly scripting language suitable for
people with little or no programming experience as well as the
seasoned web developer who needs to get things done quickly. The
best thing about PHP is that you get results quickly," said
Rasmus Lerdorf, one of the developers of the language.
"Version 3 provides a much more powerful, reliable and efficient
implementation of the language, while maintaining the ease of use and
rapid development that were the key to PHP's success in the past,"
added Andi Gutmans, one of the implementors of the new language core.
"At Circle Net we have found PHP to be the most robust platform for
rapid web-based application development available today," said Troy
Cobb, Chief Technology Officer at Circle Net, Inc. "Our use of PHP
has cut our development time in half, and more than doubled our client
satisfaction. PHP has enabled us to provide database-driven dynamic
solutions which perform at phenomenal speeds."
PHP 3.0 is available for free download in source form and binaries for
several platforms at http://www.php.net/.
The PHP Development Team is an international group of programmers who
lead the open development of PHP and related projects.
For more information, the PHP Development Team can be contacted at
core@php.net.
在PHP 3.0发布之后,用户数量真正开始激增。PHP 4.0由大量对改变PHP基本架构感兴趣的开发者促生。这些改变包括在语言和Web服务器之间的抽象层,增加了一个安全线程机制,增加了一个更加高级的、双平台的分析/执行 标签分析系统。新的解析器,由Zeev 和Andi主要编写, 被命名为Zend引擎。在很多开发人员做了大量工作之后,PHP 4.0于2000年5月22日发布。
从这个版本发布开始,只有很少的PHP 4.0的小发布版本,最新版本是4.3.11。而在本书付印后,PHP 5.0版本也将已经发布。现在已经有了一些小版本译注1发布,这些版本的稳定性也相当高。当你看到此书时,在新版本的PHP中已经有了一些重要的进步,如XML、面向对象和SQLite这些主要的改进。同时也有很多其他的小改进,如函数增加和特性的增强等等。
1.2.2 PHP的成长
The Growth of PHP
图1-1通过Netcraft (http://www.netcraft.com)自2000 1月收集的PHP使用数量来说明PHP的成长情况。这个图展示了唯一IP地址下启用PHP模块的Apache服务器的总数(含19720597个域名,1310181个IP地址)。2001年的那个低谷反映了当时互联网的“冬天”导致的很多.com公司的倒闭和消失的情况,当时Netcraft找到的服务器的数量也明显减少。你可以在以下地址看到这个统计图的最新版本:http://www.php.net/usage.php。

图1-1:2000年以来PHP应用的增长情况







