Home > Article > Backend Development > PHP Complete Manual_PHP Tutorial
1. PHP installation settings PHP can run under a variety of operating systems. Current operating systems are mainly divided into two categories, one is the Windows series and the other is the UNIX series. There are big differences in the installation and setting of PHP's operating environment in these two series of operating systems, which are described below. ##2 (1) Installation settings under UNIX-like operating systems Currently, there are two popular free UNIX-like operating systems on the market, FreeBSD and Linux. Linux systems are more popular and there are many types, such as RedFlag, RedHat and other systems. There is only one type of FreeBSD, and its current Release version is 3.5. Here, FreeBSD is used as an example to introduce the PHP installation and setup process under a UNIX-like operating system. Linux and FreeBSD are similar. 1. Installation First go to www.php.net to download the PHP installation file and http://www.apache.org to download the Apache WEB server. Generally, the downloaded files are placed in the /usr/ directory. Next, the installation settings begin. If readers do not understand the meaning of these parameters, please do not change them at will. Install Apache and PHP first. tar -vzxf apache_1.3.x --x represents the version number such as 12 or 13, etc. tar -vzxf php-4.0.x or tar -vzxf php-3.0.x cd apache_1.3.x ./configure --prefix=/ www --/www represents the installation directory under the root directory www cd ../php-4.0.x or cd ../php-3.0.x ./configure --with-mysql --with-apache=../apache_1 .3.x --enable-track-vars make 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 make install The first and second lines of the command use tar to decompress the downloaded compressed file and restore it to the directory of the same name, and then set the environment in the Apache decompression directory, - The -prefix option represents the installation directory path of Apache. Then enter the PHP decompression directory and set the PHP environment. If you are not using a MySQL database, you can omit the --with-mysql option, but you must add the --with-apache option, and the Apache decompression directory name must be correct. After setting up PHP, compile and install it into the specified directory of Apache. Then complete the installation of the PHP pattern library in the Apache decompression directory, compile and install Apache, and the installation work is initially completed. The next step is to configure Apache so that the Web Server can run smoothly. 2. Set up the php.ini file first, 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 own requirements. Of course, if the settings are not clear, the default settings will be used. Readers can also specify another directory, but they need to be specified in Chapter 1. Six steps to set conditions--with-config-file-path=/path. Then set the Apache server. You need to add the following string to the Apache configuration file httpd.conf or srm.conf. PHP 3: AddType application/x-httpd-php3 .php3 PHP 4: AddType application/x-httpd-php .php Readers can also set another suffix name as the file name of php. ##2 (2) Installation under Windows Download the PHP installation program and prepare for installation. Because the installation of the Windows series is not very different, this article takes the installation under Windows 98 as an example. You should have PWS 4.0 installed 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 (it should be c:\winnt in Windows NT and Windows 2000) ) and renamed to php.ini. Edit your php.ini file, you can change the extension_dir setting to the installation path of your php, such as "c:\php" mentioned above, select the php extension module you want to install, in the ini file Add the php_*.dll line after extension=, you can also load it dynamically in a script. PHP also provides some additional modules that can provide other functions, which can be downloaded from relevant websites. 2. Settings After completing the above steps, you need to check whether DCOM98 is installed. If not, you also need to install DCOM98, which can be found in the full version of VB6. You also need to set up the registry. Generally, the downloaded PHP compressed package contains a registry file named PWS-php4.reg. You need to modify this file with Notepad first, and replace "[PUT PATH HERE]" with the PHP decompression directory. Please note that directories must be separated by double slashes "\\".After saving, just merge it into the registry in the right-click menu. 3. PHP additional libraries (extension modules) In order to extend the functions of PHP, PHP provides many additional libraries. These additional libraries are provided in the form of DLL files. Before use, you need to modify the php.ini file and use Extention to set the required additional libraries. The following table shows commonly used add-on libraries. More add-on 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 php_ldap.dll LDAP function php_msql1.dll mSQL 1 client php_msql2.dll mSQL 2 client php_mssql.dll MSSQL client php3_mysql.dll (PHP 4 built-in) MySQL function module php_nsmail.dll Netscape mail function php_oci73.dll Oracle function module php_zlib.dll ZLib function module ##1 2. Getting started with PHP language Using PHP scripting language is not difficult, if you have a foundation in other programming languages , can be mastered quickly, even if there is no other language foundation, you can easily master it after a little more study. PHP has a more convenient special editor PHPEditor available for use. You can also use editors such as UltraEdit and Editplus, depending on your preference. ##2 (1) Grammar basics 1. How to embed PHP code in the page PHP can be embedded in the middle of the HTML code, which means that HTML and PHP codes can be mixed together, so writing code will be very comfortable. Of course, there must be a way to distinguish PHP code from HTML. You can use the following four methods: (1) echo (“这是最常用的方式”); ?> (2) (3) (4) (4) above This method requires separate settings to be used under Windows 98. 2. Program comments and how to end statements. In PHP programs, comments have the following three comment methods: (1)/* First line, second line, multi-line comment*/ (2)// Single-line comment (3)# Single line Comments The above three types of comments can be mixed, and readers can choose according to their habits. It should be noted that multi-line comments cannot be nested in multi-line comments. PHP statements are separated by ";", which is also the statement terminator. 3. Small example We have learned about the simple coding standards of PHP. Now we can write a simple example as follows: