关于PHP 5.3.0
六月三十号,PHP.net发布了5.3.0版本的Release版本。
一直没有时间来关注,今天特别去看了一下,增加了很多有意义的新特性:比如众望所归的命名空间支持。
原本以为这会在PHP6里才会实现,没想到5.3.0就增加了。在PHP6之前,5.3.0也确实算得上一个比较值得关注的版本了。
简单列举一下比较值得关注的特性,关于全部的更新日志可以参考ChangeLog(http://www.php.net/ChangeLog-5.php#5.3.0)
另外PHP团队提供了一个专题来指导如何将5.2.x的项目迁移到5.3.0,参见http://www.php.net/migration53
由于没有linux的环境,因此只能在win下分析一下,欢迎拍砖。
1、更改mysql的扩展为mysqlnd
mysqlnd是MySql专为PHP6设计的驱动,采用PHP开源协议,避免了版权争议,并且置于php内部了。仔细对比就会发现5.3.0的windows版本中少了libmysql.dll这个文件,正是因为使用了mysqlnd驱动,因此libmysql.dll这个外部驱动也没必要存在了。使用mysqlnd驱动并不会改变使用mysql或者是mysqli的使用方式,并且会提升一些性能。
2、去掉了ISAPI扩展
想要在IIS中使用PHP 5.3.0,没办法再像以前那样在IIS添加.php扩展名到php5isapi.dll上了。所以在IIS上使用PHP 5.3.0的方式只有CGI和Fast-CGI两个选择了。现在还有谁会用老古董的CGI么,所以只能用Fast-CGI了。
由于手头只有vista环境,下面将在介绍IIS7下使用PHP 5.3.0
1)打开IIS的CGI功能
依次打开 控制面板-程序-打开或关闭Windows功能,打开 Internet信息服务-万维网服务-应用程序开发功能-CGI(选中此选择框后将同时打开CGI和FastCgi功能)
2)添加PHP 5.3.0支持
打开IIS管理器,选择服务器(应用到所有网站)或者某个网站(应用到单个网站)。选择处理程序映射选项,将会列出所有程序映射。在右侧选择添加模块映射。然后路径填写为*.php(如果要处理其他扩展名,依次添加即可),模块选择FastCgiModule,可执行文件选择PHP 5.3.0下的php-cgi.exe即可。名称自定,如需要更多设置,点击请求限制。
3)设置php.ini
php.ini放置于PHP 5.3.0文件夹下即可,设置方式和以前没有什么不同。不过要设置date.timezone = Asia/Shanghai,不然运行时会报错。ok,然后就可以看phpinfo()了,需要什么扩展,自行打开就行了。
3、命名空间支持
在PHP 5.3.0中终于添加了命名空间支持。PHP程序员一直的都是很傲气的,因为他们有众多强大无比的开源项目(Drupal、Wordpress等等),可是提到命名空间却不得不无奈。现在PHP团队终于将本来构思在PHP6中的命名空间提早到了PHP 5.3.0。在PHP中使用命名空间同样使用namespace关键字。
4、静态延迟绑定
在PHP 5.3.0增加了静态延迟绑定支持。增加了使用static关键字和get_called_class()等几个函数来实现访问继承树中的特定成员。
5、闭包
PHP 5.3.0中增加了对闭包的支持,可以方便的使用匿名函数或者Lambda表达式。可以将函数放在一个变量中。这个对笔者来讲才是最期待的功能。
6、垃圾回收机制
在PHP 5.3.0中增加了可选的垃圾回收机制。作为可选的功能,看来PHP团队对这个功能也不怎么上眼。毕竟对于Web来说,页面执行完毕后,所有的资源全部释放掉了,也没必要特意的处理资源回收。聊胜于无吧。
7、优化了大量的函数,修复了大量的bug
根据PHP.NET的说法,修复了超过140个Bug。增加了若个扩展。另外优化了很多已知函数的性能,比如md5()速度就提升了10%以上。关于全部的更新,可以参考ChangeLog(http://www.php.net/ChangeLog-5.php#5.3.0)
5.3.0这个版本提供了大量的新功能,并且对整体性能进行了大幅度的优化,整体性能的提升到达10%左右。所以,可能的话,还是赶快把项目升级到5.3.0吧。
参考:
ChangeLog
Migrating from PHP 5.2.x to PHP 5.3.x
php 5.3带来了什么

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.
