A brief discussion of PHP syntax (3)_PHP tutorial

WBOY
Release: 2016-07-13 17:20:56
Original
770 people have browsed it

The previous article "Talk about PHP syntax" has already talked about PHP's data types and expressions. Now, let’s take a look at PHP variables and constants.
Let’s look at an example first.

File: test.php
//This is a single-line comment method
#This is another single-line comment method
/*This It is a method of multi-line comments
Let’s take a look at an example*/
funtion display($file,$line)
{
global $message;
echo "FILE :$file
";
echo "LINE:$line
";
echo "Message:$message
";
} $message="This is a routine. ";
display(_FILE_,_LINE_);
?>
The displayed result is:
text.php
15

This is a routine

In the above example, function is to define a custom function. The next two variables $file and $line are two local variables. They only work in the function body and do not interfere with the variables outside the function. If there is $file or $line outside the function, , the values ​​of two $files and two $lines are not necessarily the same. _FILE_ and _LINE_ are two constants, and their values ​​have already been determined. _FILE_ is the file name of this file, _LINE_ is the line number of the execution line. There is another sentence in the function body: global $message; Its function is to enable the global variable $message to be applied to the function body. This sentence can also be written as $GLOBAL["message"];
For GET, POST and PHP will automatically treat the information generated by mechanisms such as cookies as PHP variables. In this way, the information processing of submitting the form is particularly easy. As follows:
File: form.html




Username:





www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532532.htmlTechArticleThe previous article "Talk about PHP syntax" has talked about PHP data types and expressions. Now, let’s take a look at PHP variables and constants. Let's look at an example first. File: test.php //This is a...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template