Simple parsing of PHP program running process, parsing php process _ PHP Tutorial

Source: Internet
Author: User
Simple parsing of PHP program running process, parsing php process. Simple parsing of the PHP program running process, parsing of the php process has always wanted to understand the Web programming technology. PHP is an important language for Web programming. it is always said in the book that PHP is used for simple parsing of the PHP program running process on the server side, parsing the php process

I have always wanted to understand the Web programming technology. PHP is an important language for Web programming. The book always says that PHP is used for programming on the server side. However, it is hard to understand how it is used for server-side programming and how it is run. I have also read some PHP tutorials, mostly about the syntax, but I didn't give any answers to the above questions. Recently, I learned something about PHP and finally learned how to run it.

HTTP and PHP scripts
HTTP is a Request/Response-based protocol that supports Web running. The HTTP client sends a Request.
To the server, the server returns Response. The Request contains the name of the page to be accessed by the client. The server returns the webpage to which the file name points. If PHP and JavaScript are not used, HTTP transmission can only be static HTML files. That is, HTML files are not affected by user behavior and the content remains unchanged.

To implement dynamic web pages, PHP or JavaScript is required. PHP is used for programming on the server side, while JavaScript is mostly used for programming on the client side.

PHP code is executed on the server. When a user accesses a webpage containing PHP code, the Request is sent to the server, which contains the webpage file name. After receiving the Request, the server finds the file pointed to by the file name and finds that the PHP code is embedded in it. it calls the PHP interpreter to process the file, sorts the processed results to Response, and sends them to the client. PHP code can interact with databases on the server or other resources, or generate different pages based on user operations.

Therefore, the PHP script is triggered when the server receives the Request from the client. After receiving a Request, the server triggers a PHP script. after processing the script, the server returns the result to the client and waits for the next Request. After receiving the next Request, the server triggers another (or the same) PHP script. The two PHP scripts run independently of each other, and the second script is almost unaffected by the previous one.

JavaScript code is generally executed on the client, that is, processed by the browser. The client obtains JavaScript code from the server, instead of the result after the code is executed, and then calls the interpreter to execute the code.

PHP code block
PHP code can be embedded into HTML files. you can often see PHP code blocks scattered everywhere in HTML files. I have always been confused about the relationship between different PHP code blocks in the same HMTL file. PHP ignores the HTML code between two PHP code blocks.

  Test PHP Multiple Blocks  

This is HTML code.

<?php $var = 1; echo "

This is PHP code block 1.
\$var=$var

"; ?>

This is HTML code too.

<?php $var += 1; echo "

This is PHP code block 2.
\$var=$var

" ?>

There are two PHP code blocks separated by HTML code. The 1st PHP code block declares a variable $ var; the 2nd code block references $ var and changes its value. Run the above code in PHP and the output is as follows.

  Test PHP Multiple Blocks  

This is HTML code.

This is PHP code block 1.
$var=1

This is HTML code too.

This is PHP code block 2.
$var=2

$ Var can be referenced in the 2nd code blocks. Although separated by HTML code, the execution of the two sections completely ignores the HTML part. The PHP output is the same as the PHP code that is not separated by HTML below. the former only inserts the corresponding HTML code between the PHP output results.

  <?php    $var = 1;    echo "

This is PHP code block 1.
\$var=$var

"; $var += 1; echo "

This is PHP code block 2.
\$var=$var

" ?>

NLP has always wanted to understand the Web programming technology. PHP is an important language for Web programming. The book always says that PHP is used for server-side editing...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.