Key difference: PHP a server-side scripting language that has its main implementation in web development. However, it can be used as a general-purpose programming language. PHP4 and PHP5 are two versions of PHP. PHP4 was released on May 22, 2000. On July 13, 2004, PHP5 was released. It was powered by Zend Engine II. It was an improvement over PHP4 and included various new features.
PHP is a server-side scripting language that has its main implementation in web development. However, it can be used as a general-purpose programming language. PHP was originally created by Rasmus Lerdorf in 1995 and it is currently managed by The PHP Group. PHP originally stood for Personal Home Page, however it was later renamed. It now stands for PHP: Hypertext Preprocessor, a recursive acronym. PHP is free software released under the PHP License, as is incompatible with the GNU General Public License (GPL) due to restrictions on the usage of the term PHP.
PHP is an open source, server-side, HTML embedded scripting language. It can basically perform any task that other CGI programs can, but it is mainly used to create dynamic Web pages. Its main advantage is that it is compatible with many types of databases. Furthermore, PHP can talk across networks using IMAP, SNMP, NNTP, POP3, or HTTP.
PHP includes a command-line interface capability and can be used in standalone graphical applications. PHP commands can be embedded directly into an HTML source document rather than calling an external file to process data. In the HTML document, the PHP script is enclosed within special PHP tags. Due to these tags, the programmer can alternate between HTML and PHP instead of having to rely on heavy amounts of code to output HTML. Also, as PHP is executed on the server, the client cannot view the PHP code.
PHP4 and PHP5 are two versions of PHP. PHP4 was released on May 22, 2000. It was powered by the Zend Engine 1.0. After various versions, the last version of PHP4, titles PHP4.4.9 was released in August 2008. After which it was announced that PHP4 will no longer be under development and no more security updates for the version will be released.
On July 13, 2004, PHP5 was released. It was powered by Zend Engine II. It was an improvement over PHP4 and included various new features, such as improved support for object-oriented programming, the PHP Data Objects (PDO) extension and numerous performance enhancements. The PDO extension defines a lightweight and consistent interface for accessing databases. Late static binding was added in version 5.3. PHP5 was also designed to be backward compatible with earlier versions of PHP and hence should result in little functionality being broken while converting from PHP4 to PHP5.
Some differences between PHP4 and PHP5:
- PHP5 removed register_globals, magic quotes, and safe mode. This was due to the fact that register_globals had opened security holes by intentionally allowing runtime data injection and the use of magic quotes had an unpredictable nature.
- PHP4 was powered by Zend Engine 1.0, while PHP5 was powered by Zend Engine II.
- PHP5 replaced magic quotes with the addslashes() function in order to escape characters.
- PHP4 is more of a procedure language while PHP5 is object oriented.
- In PHP5 one can declare a class as Abstract.
- PHP5 incorporates static methods and properties.
- PHP5 introduces a special function called __autoload()
- PHP5 allows one to declare a class or method as Final
- PHP5 introduces a number of magic methods, such as __call, __get, __set and __toString
- In PHP5, there are 3 levels of visibilities: Public, private and protected.
- PHP5 introduced exceptions.
- In PHP4, everything was passed by value, including objects. Whereas in PHP5, all objects are passed by reference.
- PHP5 introduces interfaces. All the methods defined in an interface must be public.
- PHP5 introduces new error level defined as ‘E_STRICT’
- PHP5 introduces new default extensions such as SimpleXML, DOM and XSL, PDO, and Hash.
- PHP5 introduces new functions.
- PHP5 introduces some new reserved keywords.
- PHP5 includes additional OOP concepts than php4, like access specifiers , inheritance etc.
- PHP5 includes improved support of current content management systems.
- PHP5 includes reduced consumption of RAM.
- PHP5 introduces increased security against exploitation of vulnerabilities in PHP scripts.
- PHP5 introduces easier programming through new functions and extensions.
- PHP5 introduces a new MySQL extension named MySQLi for developers using MySQL 4.1 and later.
- In PHP5, SQLite has been bundled with PHP.
- PHP5 introduces a brand new built-in SOAP extension for interoperability with Web Services.
- PHP5 introduces a new SimpleXML extension for easily accessing and manipulating XML as PHP objects. It can also interface with the DOM extension and vice-versa.
- In PHP5, streams have been greatly improved, including the ability to access low-level socket operations on streams.
Image Courtesy: itvedant.com
Image Courtesy: krypto84sv.blogspot.com