PHP5.0 change and PHP6.0

Source: Internet
Author: User
Currently, PHP 4.x is used for most PHP installations. In fact, PHP5.0 has been released for a while, and PHP5.1.1 has just been released. If you haven't upgraded to these new versions, let's take a look at the changes in the new version of PHP. Currently, most PHP installations are still using PHP 4.x. In fact, PHP 5.0 has been released for some time, and PHP 5.1.1 has just been released. If you have not upgraded to these new versions, let's take a look at the changes in the new version of PHP and discuss the features of PHP 6 at the end.

   I. Changes to PHP 5.0

As a brand new version number, there are many essential differences between PHP 4 and PHP 5. Most of the hype is an important new object model that has been rewritten. PHP 5 is more complete and has better running performance. In PHP 4, an object is actually a rough data type and a value reference. While trying to maintain as many backward compatibility as possible, setting zend. zemo-compatibility_mode in PHP 5 can ensure compatibility with methods in version 4. Of course, PHP 5 also has some backward incompatible changes, including:

· The new key words are mostly related to the object model (exception, final, php_user_filter, inte *** ce, implements, extends, public, private, protected, abstract, clone, try, catch, throw ). The two words reserved in PHP 4 no longer exist (cfunction, old_function ).

· If an object does not have any attributes, it is no longer empty (empty ).

· Currently, the array_merge () function only receives arrays.

· Classes can be declared before the application (depending on the specific situation ).

· Get _ class (), get_parent_class () and get_class_methods () can now return a case-sensitive result, whereas the previous results are all in lowercase.

· Strrpos () and strripos () are now applied to all strings. For example, var_dump (strrpos ('abcdef', 'daf') Returns int (3) in PHP 4, and bool (false) in PHP 5)

· If $ _ SERVER exists, it will be filled with argc and argv-this promises that the CLI version can always access the data.

· When an invalid IP address is passed, ip2long () returns FALSE instead of-1.

· Functions defined in an include file can now be called as the main file at any time. If the file is included twice (the function has been defined at this time), PHP 5 will also issue a fatal error.

· The require _ once () and include_once functions are considered insensitive to Windows size and contain only one file at a time, even if the function is called multiple times with different case names.

· Get rid of the warning in PHP 4. The new PHP 5 will throw an error when encountering an invalid string offset.
  
· Tokenizer expansion does not define idle T_ML_COMMENT constants.

Note that these seemingly many incompatible changes are not big, and if you want to port the original code to PHP 5, it is possible that you only need to make a few corrections to your script. PHP 5 provides a better way to do a lot of things, but if your goal is only to make the program run, you will not encounter too much trouble. Some other changes in PHP 5 include:

· A few changes have been made to CLI and CGI scripts, effectively increasing the importance of new CLI status.

· Introduce a large number of new functions, many of which are used to process arrays, character conversion, and stream control.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.