PHP novice

zhaozj2021-02-16  88

1 Introduction

PHP is one of the tools that make you generate a dynamic web page. PHP web files are treated as a general HTML web file and you can write PHP with a general method of editing HTML when editing.

PHP Representative: Hypertext Pretreatment (PHP: Hypertext Preprocessor). PHP is completely free, don't spend money, you can freely download from the official site (http://www.php.net). PHP complies with GNU Public License (GPL), and many popular software such as Linux and Emacs were born under this license. You can get the source code unrestricted, even you can add the features you need from it. PHP can run on most UNIX platforms, GUN / Linux and Microsoft Windows platforms. How do I install PHP on a PC machine or UNIX machine in a Windows environment can be found on the official site of PHP. The installation process is simple.

If your machine solves the 2000 problem, then PHP is the same as the nematode problem!

1.1 history

Three years ago, Rasmus Lerdorf created the Personal Home Page Tools in order to create his online resume. This is a very simple language. Thereafter, more and more people have noticed this language and put forward various recommendations for their expansion. Under the selfless dedication of many people and the source code freedom of this language itself, it has evolved into a characteristic language and is now growing.

Although PHP is easy to learn, the speed is slower than mod_perl (Perl module implanted with the web server). Now there is a new engine called Zend with Mod_Perl, and PHP4 can make full use of this engine. PHP4 is also in the Beta test phase. Andy Gutmans and Zeev Suraki are the main author of Zend. You can go to the Zend site (http://www.zend.com) to learn more.

PHP's application has grown significantly in the WEB project of personal nature. According to Netcraft's report in October 1999, there were 93122 domains and 321,128 IP addresses using PHP technology.

1.2 PHP's advanced

There are many benefits to PHP. Of course, it is known that PHP is that it is an open source project, there is no commercial support, and thereby brings slowly (until PHP4). But the php list is very useful and unless you are running like Yahoo! or Amazon.com, you will not feel the speed of PHP and what else is different from others. At the very least, I didn't feel it! Ok, let's take a look at the advantages of PHP:

- learning process

I personally prefer PHP very simple learning process. Unlike Java and Perl, you don't have to work hard to learn from 100 pages of documents to write a similar program. Just learn about some basic grammar and language characteristics, you can start your PHP encoding tour. After you have encountered any trouble during the coding process, you can also go through the relevant documentation.

PHP syntax with C, Perl, ASP, or JSP. For those familiarity familiar to the above language, PHP is too simple. Conversely, if you know more about PHP, then you are very simple to learn from several other languages.

You only need 30 minutes to master all the core language features of PHP. You may have a very understanding of HTML, or you already know how to use editing design software or manual to make a good-looking Web site. Since PHP code is accessible to your site, you can easily add PHP to your site more dynamic characteristics while you can design and maintain your site.

- Database Connectivity

PHP can be compiled into a function that is connected to many database. PHP and MySQL are now a great combination. You can also write the peripheral function to take indirect access to the database. By this way When you replace the database, you can easily change the encoding to adapt to this change. PHPLIB is the most commonly used group of base libraries that provide general transactions. - Scalability

As mentioned earlier, PHP has entered a period of rapid development. For a non-channel, it is more difficult to extend additional functionality for PHP, but it is not difficult for a PHP programmer.

- Object-Oriented Programming

PHP provides classes and objects. Web-based programming work is very important for object-oriented programming capabilities. PHP supports constructors, extraction classes, etc.

- scalability

The interaction of the traditional onpage is achieved by CGI. The scalability of the CGI program is not ideal because it opens an independent process for each running CGI program. The solution is to compile the interpreter that is often used to write the language of the CGI program 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 a CGI mode. The embedded PHP can have higher scalability.

- More Features

PHP developers have developed many peripheral popular base libraries in order to make Web programming, which contain more easy to use. You can use the PHP connection including most of the databases in Oracle, MS-Access, MySQL. You can draw on flies, write programs to download or display e-mail. You can even complete the network-related functionality. Best, you can choose which features you need for your PHP installation version. Quote Nissan's xterra is that PHP can do everything you want to do and it is omnipotent!

1.3 Competitor: ASP, MOD_PERL, JSP

I certainly don't know what ASP / JSP can do. However, it is clear that there are so simple that the code will purchase them, and how expensive and powerful hardware they need. If you have any neutral point of view (for example, you are not affected by the Million Dollars of Sun and Microsoft), please let me know.

As far as I know, JSP is based on Java, so Java programmers can easily start coding. ASP is just a general engine that has the ability to support multiple languages, but the default and most commonly used or VBScript.

MOD_PERL is as strong as Perl, just faster.

2.PHP Getting Started

The online tutorial of the PHP site is already great. There are also links to some other tutorials there. This section of this article will make you familiar with PHP. I can't do any missing, my purpose is to let you start your PHP programming.

2.1 Premiere

You must first have a WEB server that is working on the PHP. I assume that all PHP files on your server are .php3.

2.2 installation of PHP

Generate a file called Test.php3 with the following:

Then open this file in your browser. Take a look at this page you will know the options for your PHP installation.

2.3 grammar

Just like mentioned above, you can mix your PHP code and HTML code. So you have to have a way to distinguish between the two. Here are several ways you can use. You can use one of you most adaptable and insist on this way!

Separate from HTML

The following is a method you can use: