In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you what are the differences between php5.2 and 5.3, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The differences between php5.2 and 5.3are as follows: 1. Php5.3 abandons Register Globals, Magic Quotes and other functions; 2, adds magic methods _ _ invoke (), _ _ callStatic (); 3, supports the definition of constants with const.
This article operating environment: windows10 system, php 5.2&&php 5.3, thinkpad T480 computer.
Many friends may not understand the difference between php 5.2 and php 5.3. Next, let's introduce in detail what is the difference between the two versions, where is the specific difference, let's take a look at it.
Let's first take a look at php 5.2.
Php5.2 (2006-2011)
Json_encode (), json_decode () and other functions have been added to JSON support.
Next let's take a look at the version of php 5.3.
Php5.3 (2009-2012)
PHP5.3 is a very big update, with a lot of new features and some incompatible changes. Let's take a look.
1. Deprecated function
The following features are deprecated, and if enabled in the configuration file, PHP will issue a warning at run time.
Register GlobalsMagic QuotesSafe Mode
two。 Anonymous function
Func=function (arg) {echo $arg;} $func ('hello'))
3. Added magic methods _ _ invoke (), _ _ callStatic ()
With the addition of anonymous functions, PHP introduces a new magic method _ _ invoke (). The magic method will be called when an object is called as a function: class A {public function _ invoke ($str) {print "A::__invoke (): {$str}";} $a = new Hello World ("Hello World"); the output is undoubtedly: A::__invoke (): Hello World__callStatic () will be called when calling a static method that does not exist.
4. Namespace, but not perfect, only classes are supported
5. Late static binding
6.Heredoc and Nowdoc
Some improvements have been made to Heredoc and Nowdoc, which are used to embed large chunks of strings in PHP code.
7. Define constants with const
PHP5.3 supports the use of const to define constants in both global namespaces and classes.
Old style: define ("XOOO", "Value"); new style: const XXOO = "Value"; const form applies only to constants, not expressions that can only be evaluated at run time: / / correct const XXOO = 1234 const XXOO / error const XXOO = 2 * 617; (after version 5.6)
8. Ternary operator abbreviated form
Old style:
Echo $a? $a: "No Value"
It can be written as follows:
Echo $a?: "No Value"
That is, if the second part of the ternary operator is omitted, the first part is replaced by default.
9.Phar
Phar, or PHP Archive, was originally just a library in Pear, but was later rewritten as a C extension in PHP5.3 and built into PHP.
Phar is used to package multiple .php scripts (you can also package other files) into a .phar zip file (usually in ZIP format).
The goal is to imitate the .jar of Java, no, to make it easier to publish PHP applications. At the same time, it also provides functions such as digital signature verification.
A .phar file can be interpreted and executed by the PHP engine like a .php file, and you can also write code like this to contain the code in (require) .phar:
Require ("xxoo.phar"); require ("phar://xxoo.phar/xo/ox.php"); these are all the contents of the article "what's the difference between php5.2 and 5.3.Thank you for reading!" I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.