An overview of the PHP programming language
- 25-07-2022
- Toanngo92
- 0 Comments
Mục lục
History of the development of the PHP language
Version | Release date | Information |
1.0 | October 1995 | In 1994, Rasmus Lerdorf first created PHP and released it under the name Personal Home Page Construction Kit |
2.0 | April 1996 | Rasmus has released a completely changed version of the previous PHP/FI code. In June 1996, The final PHP/FI 2.0 version has been released. |
3.0 | June 1997 | The first version similar to today’s PHP was PHP 3.0. The improvement of PHP/FI 2.0 is done by Andi Gutmans and Zeev Suraski of Tel Aviy, Israel. This new language was released as PHP and it removed the implication of personal usage restrictions. PHP is an acronym for Hypertext Processor |
4.0 | June 1999 | A new tool has been introduced here, improving the codebase and performance of the application complex. It is also known as ‘Zend Engine’. Besides many performance improvements, PHP 4.0 includes a number of other key features. |
5.0 | July 2004 | The core of PHP 5.0 is Zend Engine 2.0 with a new object model. PHP 5.0 is strongly introduced, supporting object-oriented programming, so Allows users to write structured and supports enterprise-layer code. |
6.0 | Skip | |
7.0 | 2019 | PHP 7.0 is the next major release after PHP 5.0. The core team made some optimizations in the interpreter, but did not introduce JIT compilation on PHP 7.0 version. This optimization is mainly done to keep backward compatible language. Optimized RAM increases usage and improves syntax in PHP 7.0 significantly. |
8.0 | 2020 | PHP 8.0 comes out with JIT compilation and new features. |
Introduction to PHP
PHP is a widely used, general-purpose, open source scripting language
for Web development. It can be written and saved as a PHP script or embedded in HTML.
PHP can be used for command line scripting and also for client-side development
Graphical User Interface (GUD) applications are platform independent.
Features of PHP
Some of the most important and well-known features of PHP are as follows:
- PHP is relatively easy to refresh and it also has many advanced features
for a professional programmer. - Efficient pronunciation on the server side.
- PHP works on many operating systems such as Linux, Windows, and Mac OS X.
- PHP is free and one can download it from the official PHP resource: www.php.net
- PHP supports many databases like Oracle, MySQL, MS SQL Server, Sybase, etc.
- PHP can dynamically generate content of HTML, PDF, Text, XML, CSV and many other formats.
- Writing programs in PHP is easy and fast, meaning it takes less time to build an application.
- Many popular PHP frameworks like Zend, Laravel and Codelgniter are available for PHP.
- Deploying hosting for PHP is easy and cheap, suitable even for small applications.
- Simple Code Deployment with PHP
PHP Scripts are widely used in the following three areas:
Server side scripting
It is the most common usage for PHP. It requires a PHP parser – PHP Parser (CGI or server module) a Web server and a Web browser.
The user must be running a Web server with PHP installed and connected.
The user can access the PHP program output with a Web browser by viewing the PHP page through the server.
All can be run locally through special software packages like XAMPP if the user is experimenting with PHP programming.
Command-line scripting
Users can run a PHP script without any server or browser.
Users only require PHP Parser to use it this way.
This usage is ideal for frequently executed PHP scripts using Task Scheduler
Command line command (on Windows) or cron command (on Unix or Linux).
Users can refer to the PHP command line for detailed information.
Writing Desktop Application
PHP is not the best language to create desktop applications with graphics) User Interface. However, if users have expert knowledge of PHP and want to use some advanced PHP features in their client-side applications, they can also use PHP.GTK to write programs. so.
PHP.GTK is an extension of PHP and is not available in the main distribution.
Users can use PHP on Linux, many Unix variants (including Solaris, HP-UX, and OpenBSD), Microsoft Windows, MacOS, RISC OS, and others. Today, PHP supports most Web servers, including Apache, IIS, and any Web server that uses Fast CGI PHP binaries, such as Nginx and Lighttpd. PHP acts as a CGI processor or as a module.
Some famous companies and applications are using PHP:
including Facebook, Wikipedia, Tumblr, WordPress and Slack, Magento.
So with PHP, users are free to choose their operating system and Web server. Furthermore, users can also choose between procedural programming and Object Oriented Programming (OOP), or a combination of both.
Users can generate output as HTML, image and PDF files. The automatic generation of text like XHTML or any other XML file can be done by PHP, saving it in the file system, instead of printing it out, thus forming a server-side cache for dynamic content.
PHP supports many types of databases. Therefore, it is very simple to write a database-enabled Web page using database-specific extensions. Users can also connect to any database that supports the Open database connection (ODC) standard using the ODBC extension.
PHP also supports connecting to other services using protocols such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (on Windows) and many more.
Users can open raw network sockets and interact using any other protocol.
PHP supports WDDX complex data exchange between virtually all Web programming languages. PHP supports instantiation of Java objects and can transparently use them like PHP objects.
PHP has useful word processing features, including Perl Compatible Regular Expressions (PCRE). In addition, there are many tools and extensions for parsing and accessing XML documents. PHP not only standardizes all XML extensions, but also extends the feature set by adding support for SimpleXML, XMLReader, and XMLWriter. Some other extensions grouped by category and alphabetically may or may not be documented in the PHP manual, such as XDebug.
PHP code example:
Create an index.php file with the following content:
<IDOCTYPE html> <html> <head> <title> Ví dụ </title> </head> <body> <?php echo "Hello, i'm toanngo92!"; ?> </body> </html>
Users who are new to PHP are recommended to start directly from PHP 8.0 to avoid the migration costs associated with previous versions. New improvements in PHP 8.0 will enable cleaner code and better performance from the start.
Users must be aware that if a lot of code is written in older versions, then migrating to PHP 8.0 will require more effort.
If users know in advance that there will be some dependencies that are not compatible with PHP 8.0 during the release process, they should try to replace those dependencies immediately. However, at the time of writing this article, my advice is still to use 7.4 and wait for the community to update with maintained projects.
Difference between PHP and JavaScript
The main difference between both is that PHP is designed for server-side scripting, while JavaScript is for client-side scripting. In PHP, the code is executed on the server and then the HTML is generated and sent to the client. The client gets the result of the script execution, but the code below is not revealed. This is very different from client-side JavaScript which is handled in the browser (client) itself. Developers can configure the Web server to process all HTML files with PHP without exposing the source code, compromising the security of business logic as well as account security.