Home Backend Development PHP Tutorial PHP多个版本的分析解释_php文摘

PHP多个版本的分析解释_php文摘

May 17, 2016 am 09:16 AM
php version

PHP版本主要分三支:PHP4/PHP5/PHP6
其中,PHP4由于太古老、对OO支持不力已基本被淘汰,就不在详述。
而PHP6由于基本没有生产线上的应用,还基本只是一款概念产品,所以也不详述。

PHP5的版本主要分三支:PHP5.2之前的版本、PHP5.2.X和PHP5.3
那我们应该如何选择适用自己项目的版本呢?
PHP5.2之前的版本不值得考虑,因为某些功能缺陷或者BUG。
主流PHP程序对PHP5.2.X的兼容性最好,而每次版本号的升级带来的都是安全性和稳定性的改善,所以宜挑选最新的版本。目前PHP5.2系列最新的是PHP5.2.14
而如果产品是自己开发自己使用,PHP5.3在某些方面更具优势,在稳定性上更胜一筹,增加了很多PHP5.2所不具有的功能,比如内置php-fpm、更完善的垃圾回收算法、命名空间的引入、sqlite3的支持等等,是部署项目值得考虑的版本。

除了版本号的不同,同一版本号的PHP版本也有区别,并且在选择PHP扩展的时候需要注意。

VC6与VC9
对于VC6还是VC9版本的选择,PHP官方网站有详细的描述
原文如下
Which version do I choose?
If you are using PHP with Apache 1 or Apache2 from apache.org you need to use the VC6 versions of PHP
If you are using PHP with IIS you should use the VC9 versions of PHP
VC6 Versions are compiled with the legacy Visual Studio 6 compiler
VC9 Versions are compiled with the Visual Studio 2008 compiler and have improvements in performance and stability. The VC9 versions require you to have the Microsoft 2008 C++ Runtime (x86) or the Microsoft 2008 C++ Runtime (x64) installed
Do NOT use VC9 version with apache.org binarieshttp://dev.meettea.com

我该选择哪个版本?
如果你在apache1或者apache2下使用PHP,你应该选择VC6的版本
如果你在IIS下使用PHP应该选择VC9的版本
VC6的版本使用visual studio6编译
VC9使用Visual Studio 2008编译,并且改进了性能和稳定性。VC9版本的PHP需要你安装Microsoft 2008 C++ Runtime
不要在apache下使用VC9的版本

TS和NTS
TS指Thread Safety,即线程安全,一般在IIS以ISAPI方式加载的时候选择这个版本。
NTS即None-Thread Safe,一般以fast cgi方式运行的时候选择这个版本,具有更好的性能。
下面给点资料,来源于 http://koda.javaeye.com/blog/662034
从2000年10月20日发布的第一个Windows版的PHP3.0.17开始的都是线程安全的版本,这是由于与Linux/Unix系统是采用多进程的工作方式不同的是Windows系统是采用多线程的工作方式。如果在IIS下以CGI方式运行PHP会非常慢,这是由于CGI模式是建立在多进程的基础之上的,而非多线程。一般我们会把PHP配置成以ISAPI的方式来运行,ISAPI是多线程的方式,这样就快多了。但存在一个问题,很多常用的PHP扩展是以Linux/Unix的多进程思想来开发的,这些扩展在ISAPI的方式运行时就会出错搞垮IIS。因此在IIS下CGI模式才是 PHP运行的最安全方式,但CGI模式对于每个HTTP请求都需要重新加载和卸载整个PHP环境,其消耗是巨大的。
为了兼顾IIS下PHP的效率和安全,微软给出了FastCGI的解决方案。FastCGI可以让PHP的进程重复利用而不是每一个新的请求就重开一个进程。同时FastCGI也可以允许几个进程同时执行。这样既解决了CGI进程模式消耗太大的问题,又利用上了CGI进程模式不存在线程安全问题的优势。
因此,如果是使用ISAPI的方式来运行PHP就必须用Thread Safe(线程安全)的版本;而用FastCGI模式运行PHP的话就没有必要用线程安全检查了,用None Thread Safe(NTS,非线程安全)的版本能够更好的提高效率。


如何查看当前运行的PHP的版本?一个很简单的办法就是phpinfo();
Thread Safety disabled是NTS,enabled是TS
Configure Command看到VC98字样的是VC6,Compiler标明 MSVC9 (Visual C++ 2008) 的是VC9

另外,顺带讲讲windows下比较简洁方便的PHP配置方法,网上教的什么复制php.ini到windows目录、复制xxxxx.dll到system32下,太丑陋了。
1、下载zip版本的PHP
2、下载好相应的扩展,修改好php.ini,添加模块映射
3、环境变量里PATH加上PHP存放的目录。只要一个就够了,/bin和/ext不需要加。
4、环境变量里定义一个PHPRC变量,内容为PHP.INI的存放路径。
完毕。很多文章提及需要重启系统,可是从我遇上的情况来看,并无必要,最多重启web服务。

如果你是linux下用,就无视本文吧。
修订: 2010-11-03

  1. 看了白菜(aiyooyoo.com)的修订,IIS安装php-cgi,3、4两步可以省略,ISAPI方式需要。
  2. 起名叫windows下的PHP版本的讲解更合适

At Last,近期思考了很多东西,若整理成文又欠缺深度和力度,还需厚积薄发。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP version development history (1995-2022) PHP version development history (1995-2022) Jun 01, 2020 pm 01:59 PM

As a PHP learner and developer, how can I not understand its history? The following PHP Chinese website will lead PHP enthusiasts to review the various historical versions of PHP.

Pagoda Panel Tutorial: A Simple Guide to PHP Version Switching Pagoda Panel Tutorial: A Simple Guide to PHP Version Switching Mar 05, 2024 am 09:27 AM

Pagoda Panel is a powerful and easy-to-use server management panel that can help users easily manage websites, databases, FTP and other services. In the process of using the Pagoda Panel, sometimes you need to switch the PHP version to adapt to different website needs. This article will provide you with a simple guide for PHP version switching, and provide specific code examples to help readers quickly complete the PHP version switching operation. First, we need to log in to the Pagoda panel and enter the website settings page. Find the "Website" option in the left navigation bar and click

Pagoda Panel Operation Guide: Sharing PHP Version Switching Tips Pagoda Panel Operation Guide: Sharing PHP Version Switching Tips Mar 04, 2024 am 10:42 AM

BTPanel is a powerful and easy-to-use server management panel that can help users easily manage servers, websites, databases and other services. As a website developer or administrator, it is very important to master the skills of switching PHP versions in the Pagoda panel. In this article, we will share how to operate and switch PHP versions in the Pagoda panel, and provide specific code examples to help readers better master this skill. 1. Log in to the Pagoda panel. First, enter the server IP address or domain name in the browser, and add the Pagoda

Understand the meaning and importance of PHP version NTS Understand the meaning and importance of PHP version NTS Mar 27, 2024 pm 12:15 PM

The meaning and importance of PHP version NTS PHP (Hypertext Preprocessor) is a widely used open source server-side scripting language that is used to develop dynamic web pages. PHP versions include NTS (Non-ThreadSafe) and TS (ThreadSafe). In this article, we will focus on the meaning and importance of NTS versions and provide some concrete code examples. The NTS version refers to the non-thread-safe version of PHP, which was originally designed to

How to deal with errors caused by PHP version upgrade How to deal with errors caused by PHP version upgrade May 11, 2023 am 08:48 AM

When developing a website or application using PHP, version upgrades are a necessary task because each version brings new features and fixes known issues. However, PHP version upgrades can also introduce new bugs because the new version may no longer support the functionality or syntax of the older version. In this article, we will introduce how to deal with errors caused by PHP version upgrade to ensure the normal operation of the application. 1. Back up the application and server. Before upgrading the PHP version, you must back up the application and server. The backup application can be

How to update PHP version in Eclipse How to update PHP version in Eclipse Mar 28, 2024 pm 09:54 PM

Eclipse is a widely used integrated development environment (IDE) that can be used to develop projects in various programming languages. When using Eclipse to develop PHP projects, it is sometimes necessary to update the PHP version to adapt to new features or fix bugs. This article will explain how to update the PHP version in Eclipse and provide specific code examples. 1. Preparations for updating the PHP version Before updating the PHP version, we need to ensure that Eclipse and the PHP development environment have been installed. in addition,

How do version updates of PHP functions affect development? How do version updates of PHP functions affect development? Apr 18, 2024 pm 02:54 PM

Impact of PHP function version updates: Impact of new features: New features are introduced to facilitate the development of complex tasks. Fix the impact of the bug: Improve function behavior and improve code stability. Impact of behavior change: Most disruptive, requiring updates to code that uses the function. Best practices: Test updates in a test environment, check interactive code, and update affected dependencies.

New features of PHP7 version and their impact on mini program development New features of PHP7 version and their impact on mini program development Jul 04, 2023 pm 06:15 PM

New features of PHP7 version and their impact on mini program development. With the continuous development of technology, the Internet industry is also changing with each passing day. In recent years, mini programs have become a hot topic in mobile application development. At the same time, the release of PHP7 version has also become the focus of developers' attention. This article will explore the new features of the PHP7 version and analyze its impact on the development of small programs. 1. New features of PHP7 version As a major update of the PHP language, PHP7 version brings many new features and performance improvements. Here are a few important new features: Sex

See all articles