If you are a network development and maintenance person, it should be quite familiar with the ASP. Since Microsoft launches ASP technology, due to its
In establishing a powerful function of a dynamic website, soon it has been widely used. But because of well known reasons, ASP can only be used for
Microsoft's own operating system and server system. Unix-based network system still occupies most;
The system is very popular because of its free and open source code, its market share has risen rapidly, and it has been said to be around 17%;
The Apache server is always the mainstream server software of the network site. The emergence and gradual improvement of PHP is based on
Network developers of UNIX / Linux system are undoubtedly good news: we can only envy ASP
Easy to use, regretted Perl / C complex!
PHP Features Overview
PHP is all called Personal Home Page, starting from 1995, and becomes a mature soft in 1998.
Piece product. The latest version is 4.0, and the common version is 3.0. PHP is written in C language, can be operated
Unix / Linux and Win9X / NT.
PHP is a cross-platform server-side embedded scripting technology. PHP page is a text file,
Is embedded in a PHP scripting statement in a normal HTML page file, interpreted and translated by the server into ordinary HTML text
Parts, then transfer to the client browser, which is the same as ASP.
PHP has borrowed the syntax of C, Java, and Perl language, and joined various PHPs.
The characteristics make the web developer to write a fast dynamic page.
The PHP script segment begins with "" As "?>". "" And "?>" Scripts
The statement is replaced with a normal HTML script after the server software calls the PHP script interpretation engine. The author believes that PHP is the most powerful and most representative characteristic lies in its database layer, which has a lot of built-in
The database is supported without special expansion, making it very simple to write a database-based web page. Currently supported database
There are Oracle, Adabas D, Sybase, FilePro, MSQL, Velocis, MySQL, Informix, Solid, DBASE,
ODBC, UNIX, DBM, PostgreSQL, MS SQL Server, etc. There are a set of functions for each database for database access and operation.
For example, if there is DBASE_create, dbase_open, dbase_close, dbase_pack, dbase_add_record,
DBASE_DELETE_RECORD, DBASE_GET_RECORD, DBASE_NUMFIELDS, DBASE_NUMRECORDS, etc.
Mysql_close, mysql_connect, mysql_create_db, mysql_data_seek, mysql_dbname, mysql_db_query
Waques.
At the same time, PHP also provides a set of image functions, which can dynamically generate image data streams in GIF format and output to
Client.
In addition, PHP also offers Socket, Email, PDF file, HIS (Hyperwave Information
Server, IMAP, LIGHTWEIGHT DIRECTORY ACCESS protocol, file upload, NIS and other functions.
Two built PHP application platform
PHP can run in a UNIX / Linux Apache server system or Win9X PWS server system or Winnt IIS server system.
Below PWIN98 PWS4.0 as an example, a PHP learning and development environment is built.
(1) Download php3 for Win9X / NT
To http://www.php.net, select Downloads, then select Download The PHP Source Code and Windows
Distribution, select a download site, then select 3.0.11 Win32 Binary. If you feel trouble, just
Use http://www.php.net/distributions/php-3.0.11-win32.zip. Download file name is PHP-3.0.11-win32.zip,
The size is 1.68m.
(2) Installing PHP3 for Win9X / NT
Installing PHP3 for Win9x / NT is simple, just decompress php-3.0.11-win32.zip into a directory. Below
In the discussion, it is assumed that the PHP3 is installed in the C: / Program files / php3 directory.
(3) Configuring php3 for Win9X / NT
Configuring php3 for Win9x / NT, that is to modify system settings, so that PWS4.0 can use the php3 script interpretation engine to explain the PHP page.
1. Copy the file php3-dist.ini in the C: / Program Files / PHP3 directory to the Windows98 installation directory (such as C: / PWIN98) and renamed it is php3.ini.
2, edit the php3.ini file
Edit the php3.ini file, change the "EXTENSION_DIR" item under "Paths and Directories" to "extension_dir
= C: / Program Files / PHP3 "; change the" browscap "item under" browscap "to" browscap = c: /pwin98/systeminetsrv/browscap.ini "(files in the PWS4.0 installation directory); in the registry HKEY_LOCAL_MACHINE / SystemCurrentControlSet / Services / W3SVC / Parameters / ScriptMap's primary key, add a string value, its name
".Php3" (PHP3 file extension), its value is "c: / program files / php3 / php.exe% s% s".
Thus, after restarting the PWS server software, PWS4.0 can explain the PHP page with the PHP3 script interpretation engine.
Three PHP script syntax
In the PHP3 file, the PHP script segment begins with "", "?>" Is ended, with "" And "?>".
Is a PHP block.
PHP grammar and C, Perl syntax is similar, mainly from C language, such as controlling flow statements and C almost exactly the same, variables
The operator is similar to C, the function definition, and the call to C is similar.
The PHP variable name must have a $$, such as $ VAR1, $ VAR2. PHP variable scope regulations are similar to C, that is, the default consider
The variable in the number is global variable, and the variables in the function are part variables.
In PHP, the ECHO and PRINTF functions are used to output HTML content to the HTML page, where echo outputs unformatted strings, PrintF
Formulated string. Such as echo ("
A PHP page
If you are familiar with C language syntax, you should not be too difficult to learn a PHP script syntax.
Founded its own simple PHP page
The so-called PHP page is inserted into some special scripting languages in a normal HTML page file and defensing PHP.
Subsequent page files, so you can easily create a simple PHP page.
Below is a simple PHP page file (TEST01.php3), it should not be difficult to understand.
hEAD>
echo ("PHP script interpretation engine has started working for you!
for ($ I = 4; $ I <= 7; $ i ) {?>
> The font size of this line of statements is
Printf ("% D", $ i);}?> font>
p>
body>
html>
Where, statement Printf ("% D", $ i);?> Is output to the value of the variable i to the HTML file.
As can be seen, you can make a normal HTML page file first, then insert the PHP scripting language in the need.
The key is to skilled application php scripting statements.
Although this page is simple, it can help familiarize and understand PHP syntax. You can view the running effect by browser, and then view the source
The function of the code looks at the source code, you can see the HTML file after the PHP page is explained. Note that the PHP page must be accessed in HTTP.
You cannot double-click the file name as a file manner as an HTML page file. If the access method on the author's computer is
http://wangfajun/test01.php3, because the PHP page requires PWS and other server software to explain.
Four access to user request information
To make a dynamic site page, getting user request information is essential. PHP pages can take advantage of this information as some applications
(If commercial order information) is based on the application requirements of the applicant.
In the ASP page, its built-in object Request can be utilized to obtain the accessor's application information. And in the PHP page, you can read
The array is obtained to obtain the accesser's application information such as form field, query information, and the like. Request page
The request information sent by the POST method can be obtained by $ http_post_vars ["itemname"], please send it in a GET method
Information can be obtained by $ http_get_vars ["itemname"], cookies information can be $ http_cookie_vars [
"ItemName"] is obtained. The general form information is sent in a POST method, which can be $ http_post_vars ["itemname"]
Way acquisition; query information is sent in a GET method, which can be obtained by $ http_get_vars ["itemname"].
(1) Request another PHP3 page processing by an HTML or PHP3 page
In the following example, the Reader Membership Registration Application page requires the applicant to fill in the full name, ID number,
Email address. The registration is notified after receiving the reader application.
Before doing a Reader Membership Registration Application page, you can be an HTML page or a PHP page. This should not be a problem.
hEAD>