Home  >  Article  >  Backend Development  >  A brief analysis of the features of the new version of PHP 5.3 (1)_PHP Tutorial

A brief analysis of the features of the new version of PHP 5.3 (1)_PHP Tutorial

WBOY
WBOYOriginal
2016-07-15 13:25:57848browse

The development from php4 to php5, from personal framework to open source framework, witnessed the development of php from copycat to regular army. php6 is still in the process of being brewed, and I believe php5 will serve as a small test site for php6. php5.3 is a milestone for php5 and adds a lot of new features.

I personally always feel that PHP has more and more functions, but the syntax of PHP is getting more and more ugly. Sometimes new functions are added, and the new functions bring problems. In order to fix the problems, it is necessary to Add new syntax to fix it, frustrating. It is estimated that PHP uses syntax to fix the problem for better parsing.

1. mysql driver mysqlnd

For a long time, php has been connected to mysql through the mysql client, and now mysql has officially launched the php version of mysql client, and This mysqlnd effectively reduces memory usage and improves performance. For details, please see:

http://dev.mysql.com/downloads/connector/php-mysqlnd/

http://forge.mysql.com/wiki/PHP_MYSQLND

A brief analysis of the features of the new version of PHP 5.3 (1)_PHP Tutorial

As can be seen from the picture, using mysqlnd eliminates the step of copying data from the mysql driver to the php extension. Mysqlnd uses copy-on-write, which means copy-on-write and read-reference.

mysqlnd has been built into the source code of php5.3. When compiling, use --with-mysql=mysqlnd, --with-mysqli=mysqlnd and --with-pdo-mysql=mysqlnd to install the mysqlnd driver.

Advantages of mysqlnd

It is more convenient to compile php, no need for libmysql, it is already built in the source code

  1. It is more convenient to compile php , no need for libmysql, already built into the source code
  2. Use PHP license to avoid copyright issues
  3. Use PHP memory management, support PHP memory limit (memory_limit)
  4. There is only one copy of all data in the memory, the previous libmysql There are two copies, refer to the picture above
  5. Provide performance statistics function to help analyze bottlenecks
  6. mysqli supports persistent connections (persistent connections)
  7. The performance is definitely faster than libmysql
  8. Add a caching mechanism in the driver layer

After seeing so many features, I feel a bit contradictory. As a database abstraction layer, can PDO bring out the features of different backends? If you use mysql as the database, is mysqli a better choice? I always feel that mysqli is just an excessive product, and PDO is the future.

2. Performance improvement

  1. md5() probably improves performance by 10%-15%
  2. Better stack implementation in the engine, I don’t understand
  3. Constants are stored in ROM (Constants moved to read-only memory), I don’t understand the meaning here
  4. Improved exception handling, opcode is more concise
  5. Solved the problem of repeated opening of include(require)_once , I used static variables to implement it once before, and finally solved this problem
  6. The binary file compiled with gcc4 will be smaller
  7. The overall performance is improved by 5%-15%

Many people think that the bottleneck of the web is the db, so they don't care about the performance of the app. I think it is mainly because app expansion is much easier than db expansion, so the db bottleneck occurs, but this does not mean that we can ignore the app's performance. Performance, after all, will ultimately solve various problems in the app. As a programmer, writing high-quality code is the most basic requirement. Programs that use less memory and execute faster are very effective under high concurrency. Sometimes if you change the implementation method, it is normal to increase it dozens of times. Of course, if you have to pay a lot but gain little, Don't be too persistent. I think you must have the awareness to write high-quality code.

3. ?: operator

is actually || in js. The result returned is not a logical type, but the value of the original variable, such as false? : 123 returns 123, not true. The syntax is a bit weird! 1

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446654.htmlTechArticleThe development from php4 to php5, from personal framework to open source framework, witnessed the transformation of php from copycat to regular army develop. php6 is still in the process of being brewed, and I believe php5 will serve as a small test site for php6. p...
Statement:
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