Ten advanced skills in PHP (on)

zhaozj2021-02-16  41

Ten advanced skills in PHP (on)

Administrators in more than 3 million Internet sites worldwide are using PHP, making it the most popular server-side scripting language. It is characterized by fast running speed, stable and reliable, cross-platform, and is open source software. Unlike the level you use, PHP can be very simple, can also be complicated, you can use it to send HTML table elements, you can also integrate Java and XML in the PHP application. If you have a certain understanding of PHP or have seen some preliminary textbooks, these techniques can expand your understanding of PHP and make you master some common and advanced PHP functions. First, the PHP is installed for Apache's DSO PHP is often used with Apache on the Linux / UNIX platform. When installing PHP, there are three installation methods to select: Static mode, Dynamic Mode (DSO), CGI binary mode. Because it is easy to maintain and upgrade, I strongly recommend installing PHP in DSO. For example, if the installed PHP only supports the database, then you want to install the encrypted module, just run "make clean", add a new configuration option, then run "make" and "make install", one The new PHP module will be installed in the appropriate location in Apache, then restart Apache without recompiling Apache. The following steps will install a new Apache, and install php: 1 in DSO: 1, get the latest version of Apache source code from the Apache Software Foundation; 2. Put the resulting source code to / usr / local / or / OPT / In the directory, or in any directory you specify; 3, running Gunzip to decompress the file, get the suffix for .tar file; 4, run the following command, install the file to the Apache_ [Version] directory: TAR-XVF Apache_ [version] .tar 5, enter the / usr / local / apache_ [version "directory (or the directory of the compressed file in step 4); 6. Type the following command to compile Apache, replace it with your own path Where [PATH], for example, / usr / local / apache [version], now has a new value of mod_so, which will allow apache to use the DSO module; 7. Type Make after returning to the prompt state, and wait back again To the prompt state; 8, execute the "make install" command. At this point, Apache has been installed and the system will return to the prompt state. Next we started to install PHP: 1, find the latest version of the link in the download area of ​​the PHP home page; 2. Download the file to an appropriate directory, such as / usr / local / or / opt / or any directory you specified Middle; 3, running Gunzip to decompress the file, get the file being a .tar file; 4, execute the following command to install the file in the php- [version] directory: TAR-XVF PHP- [Version] 5, enter / The usr / local / php- [version "directory or the directory specified in step 4; to this, it has been prepared to install PHP in DSO mode, the only configuration option that needs to be modified is with-apxs (this is apache bin One file in the directory). In order to get a high performance, I didn't install the support module for MySQL.

./configure --with-mysql = / [path to mysql] --with-apxs = / [path to apxs] 6, after returning to the prompt state, execute the make command, waiting to re-return to the prompt state; 7, execute Make install command. At this point, the system is installed in the DSO mode in the Apache's module directory and returns to the prompt state after proper modification of Apache's httpd.conf file. After returning to the prompt state, you also need to modify the apache's httpd.conf file. 1. Find a line containing serveradmin, add your email address, as shown below: ServerAdmin You@yourDomain.com 2, find the line starting with ServerName, change it to a true value, for example: ServerName Localhost 3, find The summary is as follows: # and for php 4.x, use: #addtype application / x-httpd-php .php #addtype application / x-httpd-php-source .phps modifies the content of these rows, make PHP 4.0 ADDTYPE no longer comments, and adds the file suffix name I want to use in PHP, the content above it is as follows: # and for php 4.x, use: # addtype application / x-httpd-php .php .phtml addtype application / x-httpd-php-source .phps Save File, return to the previous directory, perform the following command to restart Apache: ./bin/apachectl start If there is no error message when starting, You can test the installed Apache, PHP to test the installed Apache, PHP by creating a file named phpinfo.php, and saving this file to apache's document root (HTDOCS) , Then turn on the browser, type http: //localhost/phpinfo.php address, and there will be many variables and their values ​​on the screen. If you want to reconfigure the PHP, you need to run the make clean command again, then perform the ./configure command with a series of options, then execute the make and make install commands, a new module appears in the Apache directory module, just re-re- Start Apache loading this new module, everything is OK. Second, the most expectation of the most expectation in PHP 4.0 using the PHP itself should be supported by the conversation, and the user of PHP 3.0 must use a third party's software. Otherwise, you cannot use a dialogue, and no conversation has always been a PHP's largest shortcomings. . As long as users are browsing your website, you can use dialogue maintenance with variables related to a specific user without having to create multiple cookies, using hidden table fields or store information in the database.

Start a conversation on a web page, you will make the PHP engine know you want to start a dialog (if you haven't started) or continue the current conversation: session_start (); start a dialogue will send a conversin to the user to send a identifier string (for example 940F8B05A40D5119C030C9C7745AEAD9), in the server side, a temporary file that matches the identifier string, such as SESS_940F8B05A40D5119C030C9C7745AEAD9, which contains registered dialog variables and their values. The most common example used to display the role of the conversation is to access the counter. Start the PHP module, make sure the PHP code is the first line of the file, do not have spaces, HTML code, and other code before the PHP code. Because the conversation will send a head, if there is space and HTML code before session_start (), an error message will be obtained. You've Been here count Times. "; all access counter code is as follows Image: You've been here count time $ count Times. ";>>> It will find that the value of the variable count has increased by 1, cool.

转载请注明原文地址:https://www.9cbs.com/read-21755.html

New Post(0)