I. PHP installation and Setup can be run in a variety of operating systems. The current operating systems are mainly divided into two types: Windows series and UNIX series. There is a big difference between installing and setting the PHP runtime environment in the operating systems of these two series, which are described below. #2 (1) install and set up the two popular types of free UNIX operating systems FreeBSD and Linux on the market. Linux systems are popular and have many types, such as RedFlag and RedHat. FreeBSD has only one type. Currently, its Release version is 3.5. Here we use FreeBSD as an example to introduce the PHP installation and setting process in UNIX-like operating systems. Linux and FreeBSD are similar. 1. Install first go to www.php.net to download the PHP installation file and http://www.apache.org to download the Apache WEB server. Put the downloaded file in the/usr/directory. Next, install the settings. If you do not understand the meaning of these parameters, do not change them at will. Install Apache and PHP first. Tar-vzxf apache_1.3.x -- x represents a version number such as 12 or 13 tar-vzxf php-4.0.x or tar-vzxf php-3.0.x cd apache_1.3.x. /configure -- prefix =/www --/www indicates that the installation directory is cd under the root directory www .. /php-4.0.x or cd .. /php-3.0.x. /configure -- with-mysql -- with-apache = .. /apache_1.3.x -- enable-track-vars make install cd .. /apache_1.3.x PHP3 :. /configure -- activate-module = src/modules/php3/libphp3.a PHP4 :. /configure -- activate-module = src/modules/php4/ Libphp4.a make install command line 1 and line 2 use tar to decompress the downloaded compressed file to a directory with the same name, and then set the environment in the Apache decompress directory, the -- prefix option indicates the installation directory path of Apache. Enter the PHP decompression directory and set the PHP environment. If the MySQL database is not used, you can omit the -- with-mysql option, but you must add the -- with-apache option, the directory name for Apache decompression must be correct. After setting PHP, compile and install it to the specified directory of Apache. Then, in the Apache decompression directory, install the PHP mode library, compile and install Apache, and then complete the installation. The next step is to set Apache to make the Web Server operate smoothly. 2. set php first. INI file, cd .. /php-4.0.x or cd .. /php-3.0.x PHP3: cp php3.ini-dist/usr/local/lib/php3.ini PHP4: cp php. ini-dist/usr/local/lib/php. ini readers can edit the ini file to meet their requirements. If you do not know the settings, use the default settings. You can also specify another directory, but you need to set the condition in Step 6 -- with-config-file-path =/path and then set the Apache server. You need to set the condition in the Apache configuration file httpd. conf or srm. add the following strings to the conf file. PHP 3: AddType application/x-httpd-php3. php3 PHP 4: AddType application/x-httpd-php. php readers can also set another extension name as the php file name. #2 (2) install and download the PHP installation program in Windows. You are prepared to install the PHP installation program because the installation of the Windows series is not much different. This article takes the installation under Windows 98 as an example. You should have installed PWS 4.0 before installation. 1. install and release the compressed file to the specified directory, such as C: \ PHP \, and then copy php. ini-dist or php. ini-optimized to the c: \ windows Directory (c: \ winnt in Windows NT and Windows 2000) and rename it to php. ini. Edit your php. INI file, you can change the extension_dir settings to your php installation path, as mentioned above "c: \ php", and select the php extension module to be installed, add php _ * to extension = In the INI file _*. dll line, you can also dynamically load in the script. PHP also provides some additional modules that can provide other functions and can be downloaded from related websites. 2. After setting the preceding steps, check whether DCOM98 is installed. If not, install DCOM98, which can be found in the full version of VB6. You also need to set the registry, usually in the downloaded PHP compressed package contains a registry file named PWS-php4.reg. You must first modify this file in notepad and replace "[put path here]" with the PHP decompression directory. Note that "\" is used for directory separation. After saving the disk, right-click it and merge it into the registry. 3. the PHP additional library (extension module) provides many additional libraries for PHP to expand the functions of PHP. These additional libraries are provided in the form of DLL files and need to be modified before use. INI file. Use Extention to set the required additional libraries. The following table lists the commonly used additional libraries. More additional libraries can be downloaded from the Internet. Php_calendar.dll calendar conversion php_crypt.dll encryption module php_dbase.dll Dbase function module php_imap4r2.dll IMAP 4 function export LDAP function php_msql1.dll mSQL 1 client php_msql2.dll mSQL 2 client php_mssql.dll MSSQL client embedded (PHP 4) mySQL function module php_nsmail.dll Netscape Mail function php_oci73.dll Oracle function module php_zlib.dll ZLib function module #1. Getting started with PHP language PHP script language is not difficult. If you have other programming language basics, you can quickly master it, even if you do not have other language basics, you can easily master it. PHP has a convenient private Editor, PHPEditor, and UltraEdit and Editplus, which can be selected based on your preferences. #2 (1) syntax basics 1. how to embed PHP code on the page PHP can be embedded in the middle of the HTML code, that is, HTML and PHP code can be mixed for use, so that the code can be easily written. Of course, to distinguish PHP code from HTML, you can use the following four methods: (1) (2) (3) (4) <% echo ("You can also write like ASP style"); %> (4) in Windows 98, you must set it separately. 2. in the PHP program, there are three annotation methods: (1)/* multi-line annotation in the second line of the first line */(2) // single line comment (3) # The preceding three annotations can be used in combination. You can choose them based on your preferences. Note that multi-line comments cannot be nested with multi-line comments. PHP statements are separated by ";", which is also the statement Terminator. 3. The following is a simple example of PHP code: First PHP Program The above example is actually a standard HTML page. Because PHP is interpreted and executed, you only need to put this file in the PHP environment we set up, you can see "Hello, this is my first PHP program" in the browser ". #2 (2) constants and variables first take a look at the following example: test2_1.php The preceding example shows that the HTML header can be omitted when compiling the PHP file. 1. in the above example, "_ FILE _" is a constant, which is determined by the PHP system and represents the current FILE name of PHP. Of course, there are many constants, such as "TRUE" and "FALSE". If you need them, you can go to the official PHP website to query them. If you think constants are not enough, you can also define Constants by yourself, in the preceding example, define ("constant name" and "Constant Value") defines constants. 2. the variable PHP is very interesting. In the above example, "$ StrOutput" is a variable. We can see that there is a "$" (USD) symbol in front of the variable, so it is very good to distinguish between variables and other statements in the program. At the same time, variables in PHP can be referenced directly in the code without pre-defined, and the symbol "$" is used, we can make our program more free, not only can reference variables as usual, but can also directly write in a string, and PHP can automatically get the value of the variable, however, PHP is very case sensitive, which is clearly described in the above example. (1) The scope of a variable. Variables in PHP can be directly referenced. We define a page-level variable. What is the relationship between it and variables with the same name in the function? This is the scope of the variable, as shown in the following example: test2_2.php As shown in the preceding example, If PHP directly references a variable with the same name as a page variable in a function, it considers the variable of the function as a new variable and does not output anything, however, if we add a "global" before it, we can get the value of the variable with the same name on the page. The other way is $ GLOBALS ["strtest"]; (2) In php, the biggest difference between a variable and many common languages is that a '$' prefix is added. Why do we discuss it separately? With this prefix, It also adds a unique PHP processing method. A prefix represents a common variable, but what about two prefixes? This is the variable, so you may not understand it. Please refer to the following example. Example: test2_3.php You can basically understand $ name from the above example. The standard definition of PHP is $ {$ name }. With variables, We can dynamically add variables. This is amazing. (3) If you have learned the types of variables in other languages, you will find that PHP Defined variables do not define the types? In fact, the variables defined by PHP are of no type by default. PHP automatically determines the type of the variables during use. As shown in the following example. Example test2_4.php: