Home php教程 php手册 php5.3/php5.4与之前的版本差异以及(php5.2x/php5.4x性能对比)

php5.3/php5.4与之前的版本差异以及(php5.2x/php5.4x性能对比)

Jun 06, 2016 pm 07:53 PM
php5 php5.4 difference Version

1:Function ereg() is deprecated Error 错误对策 Deprecated: Function ereg() is deprecated in …… 解决方法一: 退回去用php5.2。 解决方法二:继续用php5.3,但是修改devel/devel.modul的460行: if ($errno (E_ALL ^ E_NOTICE)) { 改为 if ($errno (

1:Function ereg() is deprecated Error 错误对策

   Deprecated: Function ereg() is deprecated in ……

   解决方法一: 退回去用php5.2。

   解决方法二:继续用php5.3,但是修改devel/devel.modul的460行: if ($errno & (E_ALL ^ E_NOTICE)) { 改为 if ($errno & (E_ALL & ~E_NOTICE & ~E_DEPRECATED)) { 把deprecated错误给忽略掉)

   解决方法三:把ereg换成preg_match,ereg_replace也需得换成preg_replace。

    只得注意的是 ereg(’^[0-9]‘ 需修改成 preg_match(’/^[0-9]/‘

2: PHP5.3后(set_magic_quotes_runtime(),ereg() )已经关闭

        运行php程序出现以下错误
   Deprecated: Function set_magic_quotes_runtime() is deprecated


   导致这个提示的原因是在PHP5.3后此特性(set_magic_quotes_runtime())已经关闭。
   而且在PHP6中已经完全移除此特性。
   你可以注释或者删除掉出错的行,或者是在set_magic_quotes_runtime()前面加@符号。


   PHP 5.3 ereg() 无法正常使用,提示“Function ereg() is deprecated Error”。问题根源是php中有两种正则表示方法,一个是posix,一个是perl,php6打算废除posix的正则表示方法所以后来就加了个 preg_match。此问题解决办法很简单,在ereg前加个过滤提示信息符号即可:把ereg()变成@ereg()。这样屏蔽了提示信息,但根本问 题还是没有解决,php在5.2版本以前ereg都使用正常,在5.3以后,就要用preg_match来代替ereg。所以就需要变成这样,原来:

   ereg("^[0-9]*$",$page)

   变成:

   preg_match("/^[0-9]*$/",$page)

   特别提醒:posix与perl的很明显的表达区别就是是否加斜杠,所以与ereg相比,后者在正则的前后分别增加了两个”/”符号,不能缺少。
   Tips:此问题在php5.2之前版本不会出现。

   Function ereg() is deprecated in drupal-6.15\includes\file.inc on line 904
   open the file.inc in a good text editor other than notepad, go to the line number 904 to see the following line. Then comment the line and in the next line type the replaced code. this will solve the instalation issues and also most of other issues related to the same issue.

   Change

   elseif ($depth >= $min_depth && ereg($mask, $file)) {

   to
   elseif ($depth >= $min_depth && mb_ereg($mask, $file)) {

   mb_ereg fortunatly is not deprecated


PHP 5.4发布了,兄弟说他代码报错了:
“Call-time pass-by-reference has been removed ”

你准备升级到 PHP 5.4了吗?
大蛇这就来八一八新版本的差异。以下排序依照对开发影响的大小。

========================================================
“Call-time pass-by-reference has been removed ”
调用时引用传递已被废弃。
当我们这样使用函数(或者类)的话,会产生一个error:
foo(& $var);
实际上,这样用本来就是错的,只是之前的错误级别仅仅是Deprecated而已。
而正确的使用方法应该是在函数定义时:
function foo(& $var) {
}
而在调用时直接传参就行了: foo($var);

========================================================
时区(timezone)必须设置
如果没有通过在配置文件中配置date.timezone 或者代码中通过 date_default_timezone_set()的方式来设定时区的话,以前会进行一些推算,而5.4以后则会删除这个特性。取而代之的是使用“UTC”时间。(点击查看什么是“UTF时间”)

========================================================
E_ALL现在包含E_STRICT
众所周知E_STRICT是不包含在E_ALL里面的,所以我们才会有E_ALL & E_STRICT这种写法。
而到了PHP 5.4中,E_ALL将包括E_STRICT。

========================================================
register_globals被移除
相信很多的PHP都对register_globals深恶痛绝,而register_globals也被认为是万恶之首,早在4.2的时候,register_globals就默认关闭了,而到了5.4就把register_long_arrays和register_globals移除了。One Less Thing to Worry About。

========================================================
默认字符集变成UTF-8
配置文件中的default_charset由原来的ISO-8859-1变成UTF-8。

========================================================
session_is_registered(), session_register() 和 session_unregister() 函数被移除.
这些函数在PHP 5.3中已经被废弃,如果要使用,可以直接对$_SESSION变量用isset(),unset()这样的方式。这些方法被移除后,如果使用会导致error。

========================================================
magic_quotes_gpc和相关的所有函数、ini中的设置
被移除的有配置中的magic_quotes_gpc, magic_quotes_runtime 和 magic_quotes_sybase。而get_magic_quotes_gpc, get_magic_quotes_runtime 虽然被保留了,但是始终会返回 false, set_magic_quotes_runtime 会产生E_CORE_ERROR错误。

========================================================
EXT/SQLITE扩展被移除
别太惊讶了,这次被移除的扩展仅仅是ext/sqlite, 而ext/sqlite3 以及 ext/pdo_sqlite并没有被移除。

以上便是这次新版本值得注意的地方,下面这里有完整版,不过是随时在变的,可能你在看这边文章点过去并非一开始就是本文所属的这些修改。
http://php.net/ChangeLog-5.php




php5.2X与php5.4x性能对比:

硬件环境:

服务器:DL180G6   (16  Intel(R) Xeon(R)CPU           E5620  @2.40GHz)        16G内存

压力机:DL180G6   (16  Intel(R) Xeon(R)CPU           E5620  @2.40GHz)        16G内存

 

软件环境:

nginx1.2.5php5.4.9/5.2.16   XCache3.0.0 最大600php-fpm

 

网络环境:千兆

 

测试场景:

php 设置两种不同版本,在相同硬件和网络环境,压力配置情况下,并发相同用户数向服务器发送请求。对比服务器资源占用和事物处理能力。

 

测试结果:

 

并发用户

CPU(us+sy)

Load average

Response time(s)

QPS/s

20

46%

9.2

0.022

950

40

49%

13.4

0.032

890

60

52%

22.8

0.043

860

80

54%

28.3

0.055

840

100

55%

42.1

0.064

820

                                                                 PHP 5.2.16版本

并发用户

CPU(us+sy)

Load average

Response time(s)

QPS/s

20

48%

8.7

0.018

1100

40

50%

14.6

0.026

1050

60

54%

21.3

0.036

1010

80

56%

26.3

0.046

998

100

57%

34.7

0.054

1020

                                                                PHP 5.4.9版本
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

Video Face Swap

Video Face Swap

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

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)

How to quickly check numpy version How to quickly check numpy version Jan 19, 2024 am 08:23 AM

Numpy is an important mathematics library in Python. It provides efficient array operations and scientific calculation functions and is widely used in data analysis, machine learning, deep learning and other fields. When using numpy, we often need to check the version number of numpy to determine the functions supported by the current environment. This article will introduce how to quickly check the numpy version and provide specific code examples. Method 1: Use the __version__ attribute that comes with numpy. The numpy module comes with a __

How to check maven version How to check maven version Jan 17, 2024 pm 05:06 PM

Methods to check the maven version: 1. Use the command line; 2. Check the environment variables; 3. Use the IDE; 4. Check the pom.xml file. Detailed introduction: 1. Use the command line, enter "mvn -v" or "mvn --version" in the command line, and then press Enter. This will display the Maven version information and Java version information; 2. View the environment variables , on some systems, you can check the environment variables to find the Maven version information, enter the command on the command line, and then press Enter, etc.

Tutorial on updating curl version under Linux! Tutorial on updating curl version under Linux! Mar 07, 2024 am 08:30 AM

To update the curl version under Linux, you can follow the steps below: Check the current curl version: First, you need to determine the curl version installed in the current system. Open a terminal and execute the following command: curl --version This command will display the current curl version information. Confirm available curl version: Before updating curl, you need to confirm the latest version available. You can visit curl's official website (curl.haxx.se) or related software sources to find the latest version of curl. Download the curl source code: Using curl or a browser, download the source code file for the curl version of your choice (usually .tar.gz or .tar.bz2

750,000 rounds of one-on-one battle between large models, GPT-4 won the championship, and Llama 3 ranked fifth 750,000 rounds of one-on-one battle between large models, GPT-4 won the championship, and Llama 3 ranked fifth Apr 23, 2024 pm 03:28 PM

Regarding Llama3, new test results have been released - the large model evaluation community LMSYS released a large model ranking list. Llama3 ranked fifth, and tied for first place with GPT-4 in the English category. The picture is different from other benchmarks. This list is based on one-on-one battles between models, and the evaluators from all over the network make their own propositions and scores. In the end, Llama3 ranked fifth on the list, followed by three different versions of GPT-4 and Claude3 Super Cup Opus. In the English single list, Llama3 overtook Claude and tied with GPT-4. Regarding this result, Meta’s chief scientist LeCun was very happy and forwarded the tweet and

How to easily check the installed version of Oracle How to easily check the installed version of Oracle Mar 07, 2024 am 11:27 AM

How to easily check the installed version of Oracle requires specific code examples. As a software widely used in enterprise-level database management systems, the Oracle database has many versions and different installation methods. In our daily work, we often need to check the installed version of the Oracle database for corresponding operations and maintenance. This article will introduce how to easily check the installed version of Oracle and give specific code examples. Method 1: Through SQL query in the Oracle database, we can

Check the Kirin operating system version and kernel version Check the Kirin operating system version and kernel version Feb 21, 2024 pm 07:04 PM

Checking the Kylin operating system version and kernel version In the Kirin operating system, knowing how to check the system version and kernel version is the basis for system management and maintenance. Method 1 to check the Kylin operating system version: Use the /etc/.kyinfo file. To check the Kylin operating system version, you can check the /etc/.kyinfo file. This file contains operating system version information. Execute the following command: cat/etc/.kyinfo This command will display detailed version information of the operating system. Method 2: Use the /etc/issue file Another way to check the operating system version is by looking at the /etc/issue file. This file also provides version information, but may not be as good as the .kyinfo file

Simple steps to update pip version: done in 1 minute Simple steps to update pip version: done in 1 minute Jan 27, 2024 am 09:45 AM

Done in one minute: How to update the pip version, specific code examples are required. With the rapid development of Python, pip has become a standard tool for Python package management. However, as time goes by, pip versions are constantly updated. In order to be able to use the latest features and fix possible security vulnerabilities, it is very important to update the pip version. This article will explain how to quickly update pip in one minute and provide specific code examples. First, we need to open a command line window. In Windows systems, you can use

How to tell whether the dp interface is 1.2 or 1.4? How to tell whether the dp interface is 1.2 or 1.4? Feb 06, 2024 am 10:27 AM

The DP interface is an important interface cable in the computer. When using the computer, many users want to know how to check whether the DP interface is 1.2 or 1.4. In fact, they only need to check it in GPU-Z. How to determine whether the dp interface is 1.2 or 1.4: 1. First, select "Advanced" in GPU-Z. 2. Look at "Monitor1" in "General" under "Advanced", you can see the two items "LinkRate (current)" and "Lanes (current)". 3. Finally, if 8.1Gbps×4 is displayed, it means DP1.3 version or above, usually DP1.4. If it is 5.4Gbps×4, then

See all articles