PHP is an easy-to-learn and use server-side scripting language. It requires very little programming knowledge to build a truly interactive WEB site using PHP. This tutorial does not want you to fully understand this language, it just allows you to join the ranks of developing dynamic web sites as soon as possible. I assume you have some basic knowledge of HTML (or HTML editor) and some programming ideas.
1. Introduction
PHP is one of the tools that allows you to generate dynamic web pages. PHP web files are processed as general HTML web files and you can write PHP in the usual way of editing HTML.
PHP stands for: Hypertext Preprocessor (PHP: Hypertext Preprocessor). PHP is completely free and you don’t have to spend money. You can download it freely from the official PHP site (). PHP complies with the GNU Public License (GPL), under which many popular software such as Linux and Emacs were born. You can obtain source code without restrictions, and you can even add the features you need from it. PHP works on most Unix platforms, GUN/Linux and Microsoft Windows platforms. Information on how to install PHP on a PC or Unix machine in a Windows environment can be found on the official PHP site. The installation process is very simple.
If your machine solves 2000 problems, then PHP also has no Millennium Bug problem!
1.1 History
Three years ago, Rasmus Lerdorf created "Personal Home Page Tools" to create his online resume. This is a very simple language. After that, more and more people noticed the language and made various suggestions for its expansion. With the selfless dedication of many people and the free nature of the source code of this language itself, it evolved into a language with rich characteristics and is still growing.
Although PHP is easy to learn, it is slower than mod_perl (perl module implanted into web server). Now there is a new engine called Zend that can be comparable to mod_perl speed, and PHP4 can make the most of this engine. PHP4 is still in the BETA testing stage. Andy Gutmans and Zeev Suraki are the main authors of Zend. You can go to Zend site() to learn more.
The application of PHP has grown significantly in web engineering of personal nature. According to Netcraft's October 1999 report, 931,122 domains and 321,128 IP addresses utilize PHP technology.
1.2 The advanced aspects of PHP
There are many benefits to applying PHP. Of course, the known disadvantage is that PHP is an open source project, has no commercial support, and the resulting slow execution speed (until PHP4). But PHP's mailing list is very useful and unless you're running a very popular site like Yahoo! or something like that, you won't feel that PHP's speed is any different from the rest. At least I didn't feel it! OK, let's take a look at what advantages PHP has:
- Learning process
I personally prefer the very simple learning process of PHP. Unlike Java and Perl, you don’t have to bury your head in more than 100 pages of documents to study hard to write a decent program. Just understand some basic grammar and language features and you can start your PHP coding journey. After that, if you encounter any trouble during the encoding process, you can also read the relevant documents.
PHP syntax is with C, Perl, ASP or JSP. For those who are more familiar with one of the above languages, PHP is too simple. On the contrary, if you know a lot about PHP, it will be easy for you to learn several other languages.
You only need 30 minutes to master all the core language features of PHP. You may already have a good understanding of HTML, and you even know how to use editing and design software or manual work to create a good-looking WEB site. Because PHP code can be added to your site without barriers, you can easily add PHP to make your site more dynamic while designing and maintaining your site.
- Database connection
PHP can be compiled into functions that have connections to many databases. PHP and MySQL are the best combination now. You can also write peripheral functions yourself to obtain indirect access to the database. In this way, when you change the database you are using, you can easily change the encoding to adapt to such changes. PHPLIB is the most commonly used series of base libraries that can provide general transactions.
- Scalability
As mentioned earlier, PHP has entered a period of rapid development. Extending additional features to PHP may be difficult for a non-programmer, but not for a PHP programmer.
- Object-Oriented Programming
PHP provides classes and objects. Web-based programming work requires object-oriented programming capabilities very much. PHP supports constructors, extract classes, etc.
- Scalability
Traditional interactions on web pages are achieved through CGI. The scalability of CGI programs is not ideal because it opens a separate process for each running CGI program. The solution is to compile the interpreter that is often used to write CGI programs into your web server (such as mod_perl, JSP). PHP can be installed in this way, although few people are willing to install it in CGI like this. Embedded PHP can have higher scalability.
- More features
In order to be more suitable for web programming, PHP developers have developed many popular peripheral libraries, which contain easier-to-use layers. You can use PHP to connect to most databases including Oracle, MS-Access, and Mysql. You can draw pictures on flies, write programs to download or display e-mail. You can even complete network-related functions. Best of all, you can choose which features your PHP installation version requires. To quote Nissan's Xterra, PHP can do everything you want it to do and do everything!
1.3 Competitors: ASP, mod_perl, JSP
Of course I don't know what ASP/JSP can do. But it is clear how easy it is to write code like that, how expensive it is to buy them, and how expensive and powerful hardware they require. If you have any neutral point of view (such as not being influenced by SUN and Microsoft's million dollars), please let me know by the way.
As far as I know, JSP is based on Java, so Java programmers can easily start coding. ASP is just a general engine with the ability to support multiple languages, but the default and most commonly used VBScript is still the one.
mod_perl is as powerful as Perl, but is faster.