Cookies and session s:
Difference between cookie and session: Cookie data exists locally, while session data exists on the server side. Session is more secure than cookie.
cookie: it is used to remember what the client has done during the http session. It can solve the problems such as advertising on the first landing page. The server and the client are stateless when developing: it means that the two do not know each other after the interaction between the server and the client. Its use is as follows:
Generation of dynamic web pages:
So far, we can put the static web page on the server, and the client requests the website through the domain name, but for us, what Apache does is too simple, Nothing more than requesting the corresponding file - reading the file - responding the file content to the client browser (the file is given to the user intact, which can not meet the need to make the content of the web page move and change dynamically with the data). So someone put forward the concept of server-side dynamic web page. There are many technologies that can realize this concept: JSP and ASP Net PHP node, etc. The principle of these technologies is not to write HTML fixedly. Each time the user requests, the code will be executed dynamically to temporarily generate an HTML page that the client wants.
web server workflow:
1. Judge whether it is a static file according to the file type corresponding to the requested URL
2. If the request is a static file, directly read the contents of the file and return the contents of the file to the client
3. If the requested file is not a static file, read the file code, execute this code (give it to other programs for execution, such as php), and return the string obtained from the execution result to the client.
Configure php extensions for Apache:
Because Apache can't handle dynamic web pages, it needs php to complete the development of dynamic web pages. So how to connect php and Apache? The specific process is as follows:
1.First, you need to Apache Configuration file for httpd.conf Custom write in file php stay Apache Module configuration instructions in: loadModule Custom name_module C:/php Installation path/php7apache2_4.dall，For example: LoadModule php7_module C:/F/php/php7apache2_4.dll 2.Continue in Apache Add this instruction to: AddType application/x-httpd-php .php To specify php This module does not judge whether to use the suffix according to the media type php Work, but according to MIME Type Judge whether it is php work 3.Configure the top Apache After configuring the file, go to php Official website: https://www.php.net/downloads after downloading the PHP compressed package, unzip the PHP compressed package to a directory. Note that it is the same as httpd The path in conf configuration is consistent; Note: some servers support PHP and can be used directly without downloading the PHP installation package. Tip: for beginners or developers who do not want to configure the environment, you can use the integrated environment for fool installation. For details, please read the official documents.
Apache and php:
For many beginners, it's easy to mix Apache and php together. In fact, they have their own areas of responsibility and responsibilities, but when we use php to make dynamic web pages, both of them will have a relationship:
Client request - Apache judges whether it is a static web page. If so, it processes it by itself, reads the file, and responds to the result to the client; Otherwise, give it to php to read the code in the php file and execute the code, return the executed code to Apache, and then present it to the client.
After the above brief introduction, I have a preliminary understanding of PHP. If I want to learn PHP well, I have to continue to refer to the official documents to learn relevant API s. For details, please refer to the following documents: http://php.net/manual/zh/index.php
The value of php: get some specified data by executing php code and fill it into the specified location of html
php(PHP:Hyper Preprocessor) is a widely used scripting language. It can be embedded into HTML, especially suitable for dynamic website development. The characteristics of php are similar to other script sounds, including variables, functions, loops, and so on. The grammar is different, but the concept is basically the same. The main function of using php is to write dynamic web pages. The core of dynamic is to make HTML no longer write dead, but to achieve dynamic purpose by embedding a piece of code that can be executed on the server in HTML.
php is often used for the output instruction of test results: echo can print multiple parameters, print can only print one parameter, var_dump() output data type and data;
Tip: the pictures and other materials in this article come from the Internet. If there is infringement, please send an email to: email@example.com Contact the author to delete.