advertisement
What is PHP and how it works
PHP is a widely used open-source general-purpose scripting language, suitable for web development. It can be written and saved as a PHP script or embedded into HTML. PHP can be used for command line scripting and also for developing client-side graphical user interface GUI application data platform independent. The user can use PHP on Linux, many Unix variants (Including Solaris, HPUX, and open BSD), Microsoft Windows, macOS, RISC OS, and others. Today, PHP supports most web servers, including Apache, IIS, and any web server utilizing the fast CGI PHP binary, such as Nginx and Lighttpd. PHP works either as a CGI processor or as a module.
Therefore with PHP, the user is free to choose an operating system and a web server. Furthermore, the user can also choose between procedural programming and object-oriented programming (OOP), or a mixture of both. The user can generate output in the form of HTML, images, and PDF files. The auto-generation of text such as XHTML or any other XML file can be done by PHP, saving in the file system, instead of printing it out, thus forming a server-side cache for dynamic content. PHP supports a wide range of databases. Therefore, it is very simple to write a database-enabled web page using database-specific extensions. The user can also connect to any database that supports the open database connection (ODC) standard using the (ODBC) extension.
PHP also supports connectivity to other services using protocols such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (on Windows), and many others. The user can open raw network sockets and interact using any other protocol. PHP has support for the WDDX complex data exchange between virtually all web programming languages. PHP has support for the instantiation of Java objects and can use them transparently as PHP objects.
PHP has useful text processing features, including Perl-compatible regular expressions (PCRE). Additionally, there are many tools and extensions for parsing and accessing XML documents. PHP not only standardizes all of the XML extensions, but it also extends the feature set by adding support for SimpleXML, XMLreader, and XML writer. Several other extensions are grouped by category and alphabetically that may or may not be documented within the PHP manual itself, such as XDebug. PHP pages have HTML tags with embedded code. The PHP code is enclosed within the PHP tags, thereby allowing the developer to invoke PHP code blocks in an HTML file. PHP marks the start processing instruction while denoting the end processing instruction.
It is recommended for users new to PHP to start directly from PHP 8.0 to avoid migration costs associated with previous versions. The new improvements in PHP 8.0 will allow cleaner code and better performance right from the beginning. The user must note that if more code is written in older versions, then migration to PHP 8.0 will require more effort. If users know in advance that there will be some dependencies incompatible with PHP 8.0 during release, then the effort should be made to replace those dependencies right away.
How PHP Works
Here's a high-level overview of how PHP works:
- PHP code is embedded into HTML or other document formats. The PHP code is enclosed within php tags, which tell the server to interpret the code within those tags as PHP code.
- When a user requests a PHP web page from a server, the web server passes the request to the PHP interpreter.
- When a user requests a PHP web page from a server, the web server passes the request to the PHP interpreter.
- The generated HTML or other output is then sent back to the user's web browser as a response to their request.
- PHP can interact with a variety of data sources, including databases, files, and APIs, allowing it to dynamically generate content based on user input or other variables.
- PHP also provides a range of built-in functions and libraries that developers can use to perform common tasks, such as sending email, parsing XML, or manipulating images.
- PHP scripts can be run on a variety of web servers, including Apache, Nginx, and Microsoft IIS, and can be integrated with various content management systems and frameworks, such as WordPress, Drupal, and Laravel.
How is Hypertext Preprocessor different from JavaScript?
The key difference between the two is that PHP is designed for server-side scripting, whereas JavaScript is for client-side scripting. In PHP, the code is executed on the server and then, HTML is generated and sent to the client. The client receives the result of script execution, but the underlying code is not exposed. This is very much different from client-side JavaScript which is executed within the browser (client) itself. The developer can configure the webserver to process all HTML files with PHP without exposing the code.
What differentiates PHP from client-side JavaScript is that the execution of code is done on the server, which generates HTML to send to the client. The client receives the output of that running script, but would not know about the code inside it. The user can even configure the webserver to process all HTML files with PHP.
History of PHP
PHP Version | Release Date | Notes
- 1.0 | October 1995 | In 1994, Rasmus Ledford first created PHP and released it under the name personal homepage construction kit.
- 2.0 | April 1996 | Rasmus released a complete makeover of the earlier code as PHP/ F1. In June 1996, the complete PHP/ F1 version 2.0 was released.
- 3.0 | June 1997 | The first version which resembles today's PHP was PHP 3.0. The inefficiency of PHP/ F1 2.0 was realized by Andi Gutman and Zeev Sursaski of Tel Aviv, Israel. This new language was released as PHP and it removed the implication of limited personal use. PHP was the recursive acronym for hypertext preprocessor.
- 4.0 | June 1999 | A new engine was introduced here, which improved the code base and the performance of complex applications. It was dubbed as 'Zend engine' after the names of Zeev and Andi. Besides the much-improved performance, PHP 4.0 included several other key features.
- 5.0 | July 2004 | The core of PHP 5.0 was the Zend engine 2.0 with a new object model. PHP 5.0 introduced powerful object-oriented programming support, thereby allowing users to write structured and enterprise-level code.
- 7.0 | 2019 | PHP 7.0 was the next major release after PHP 5.0. The core team made several optimizations in the interpreter but did not introduce the JIT compilation in PHP 7.0 version. These optimizations were mainly done to keep the language backward compatible. Optimized RAM usage and improved syntax in PHP 7.0 boosted performance significantly.
- 8.0 | 2020 | PHP 8.0 came up with JIT compilation and other features.
advertisement
Conversation
Your input fuels progress! Share your tips or experiences on prioritizing mental wellness at work. Let's inspire change together!
Join the discussion and share your insights now!
Comments 0