Panty story after desk interactive PHP

Source: Internet
Author: User
Tags null null
Hello, ladies and gentlemen, welcome to the program of the underwear and the monkey's IT program Big Lecture hall, today to share a little knowledge point on that's the point of the foreground and background interaction. PHP

There are two noun explanations in PHP. It is also a description of our current app client and the difference between the Web page.

BS Download-Free browsing

CS need to download browse

Construction of the environment

You need to download a XAMPP software on the network. To install. The individual is using the XAMPP for Mac version.

Let's start by saying what we need to use PHP.

MYSQL Apache (middleware) PHP These three, and why I recommend you install XAMPP, because he has all of our three things have been packaged. Just install the next step. If a single installation is very complicated for us, we recommend that you install XAMPP directly.

All right, about the installation of XAMPP. You can go and search for it. The next step is straightforward.

How PHP tags are declared

echo "

Hello Word

";? >

Hello Word

In PHP, the table is declared with the end. Echo for the print/output meaning.

And our statement documents are also based on * * *. PHP for the end of the file.

PHP comments

Single-line Comment

#这也是单行注释

/*

Multiple lines of comment, he spanned many lines

*/

?>

Variable

The variable is preceded by $, followed by the variable name.

With letters. Numbers. Underscores, and cannot begin with a number.

is case sensitive.

Chestnuts:

$name = "Neiku";

$age = 26;

$num = 15+ "12"; $num = 27;

In PHP, the plus sign is the sum, and he doesn't know whether the subsequent number is a string type. But if it is 15+ "Ab12", then his value is 15, he will skip AB12. But with 15+ "12ab", his value is still 27.

Assigning values to variables

There are two types of assignments: direct assignment, reference assignment.

Chestnuts:

$sum = "Hello";

$sum 2 = & $sum; After the & is added here, $sum will assign his memory address to $sum2. If the $sum2 is re-assigned, the value of the $sum will change. This is a bit like a C-language pointer.

Variables of variable

Chestnuts:

$sum = "Hello";

$ $sum = "word";

Echo $sum; Output Hello;

echo ${$sum}; Output word;

Echo $hello; Output word;

Here, the variable is preceded by a new value that can be added to the assignment value. He will generate a new value. This is a little bit weird, really. As for the usefulness ... Said it was a big use. This is in our forin and he can use it while he's walking.

Super Global variables

PHP provides a number of useful and predefined variables. Used to provide a large amount of environment-related information.

Print/Output Global variables: Print_r ($_server); Here's an explanation for print_r. He prints an array. Used for array-specific printing. And all of our predefined variables are array types. So he needs to use Print_r to print.

Print_r ($_server);

He will print out all of your information.

All information

And here I'm going to list some of the ways we used to do it alone.

Print_r ($_server[' server_name ');

He will return the hostname of the server where you currently run the script.

The host name of the current server script.

If you change 127.0.0.1 to localhost, his hostname will change to localhost or the IP of your current computer in front of it, and he will become IP.

Print_r ($_server[' remote_addr ');

The client IP address.

IP Address

But notice that here he gets only the current IP address, but he doesn't recognize localhost.

Print_r ($_server[' Request_uri '):

Gets the current file path.

Current file path

Print_r ($_server[' http_user_agent ');

Gets information about the current operating system and browser.

My system, my browser, my middleware

$_get

The variable contains information about the parameters passed using the Get method.

Then write the PHP code in the index.php file.

$name = $_get[' name '];

$pwd = $_get[' pwd '];

Echo $name;

echo "
";

Echo $pwd;

?>

Enter information on the page

321 321

321 321

After submission, the page is displayed

321 321

However, please note that the Get method will display your input information on the URL.

Display your input information

So let me introduce you to post.

Post

The variable contains information about the parameters passed using the Post method.

HTML code as above, I will not write. Depressed, do not let copy of our posts. The only difference is that method= "post" his request changed to post

PHP code ditto.

Enter information on the page

321 321

321 321

After submission, the page is displayed

321 321

And this time, the page will not have your input information.

$_request

This variable records the variables passed to the script through various input methods. such as Get,post, but do not use this super variable, because it is unsafe and slow.

$_cookie

Array of cookie variables

$_session variable Array

Array of Session Variables

$_file

Array of variables related to uploading files

$_env

Array of environment variables

$_globals

All global variable arrays

Constant

A constant is a value that cannot be modified in the execution of a program. such as Pi (3.14159236);

Constants are case-sensitive, and often the constant name is always uppercase.

Constants are global and can be used anywhere in the script.

Constants are divided into built-in constants and custom constants;

Constants are defined using the Define () function.

Chestnuts:

Define (' PI ', 3.1415926);

Echo PI; 3.1415926

Built-in constants

Php_os the constant of the operating system where PHP resides.

Php_version The version number of the current PHP.

Magic Constants

The current line number in the __line__ file.

The full path and file name of the __file__ file;

The name of the __FUNCTION__ function.

The __class__ class name.

The method name of the __method__ class.

Data type

String

There are three ways to define strings: single quotes, double quotes, delimiters;

A variable that appears in a single-quote string is not substituted by the value of the variable.

The most important point in a double-quote string is that the variable is substituted by the value of the variable.

If you encounter the dollar sign $, the parser will get as many of the following words as possible utilises make up a valid variable name, if you want to explicitly specify the end of the name, enclose the variable name in {} brackets.

Chestnuts:

$ sum = "Hello";

echo = "Welcome to China, I am * * *, {sum}s";

Method of string delimitation using delimiter syntax <<<

Chestnuts:

$str = <<< AAA

Dasfdas FDSAFDASFDSA

Fdsafdsaf FDSASADF

AAA;

Echo $str; Dasfdas FDSAFDASFDSA Fdsafdsaf FDSASADF

Str

Str

Here's what to note:

The line where the end identifier is located cannot contain any other characters, which means that the identifier cannot be indented, preceded by a semicolon, and cannot have any spaces or tabs.

String to change the meaning

\ n line break \ r enter \ t water tab (tab);

\ \ (backslash) \$ $ (dollar symbol) \ "" (double quotes)

Plastic

$age = 25;

Floating point Type

$age = 5.29;

Boolean type

$bu = TRUE;

$bu = FALSE;

Composite data types

Array

$week = Array (' Monday ', ' Tuesday ', ' Wednesday ');

Object

$DB = new db;

Special data types

Resources

$fh = fopen ("Text.txt", "R"); Open a file or path. If it fails, it returns false.

Null

Null no, indicates no value, NULL does not represent a space, nor does it indicate 0, the following case is considered null;

No predefined variables are set.

definite assignment null;

Use the function unset () to clear.

Automatic type conversion

Because PHP is loosely defined for type definitions. It is sometimes based on the context of the reference variable. Automatically converts a variable to the most appropriate type.

Chestnuts:

$num = 5;

$STR = "15";

echo $num + $str; 20;

$str = "Hello";

$num = 200;

echo $str + $num; 300

$STR = ' 1.2 ';

if ($STR) {//Judge $str to True or false

echo "Hello word";

}//Hello word;

Type-dependent functions

GetType () returns the type of the variable. A total of 8 types.

String strings

Integer shaping

float Float Type

Boolean Boolean

Array arrays

Object objects

NULL NULL

Unkonw Unknown

Chestnuts:

$sty = "Hello";

Echo GetType ($sty); String

Is_type ();

To see if a variable belongs to a type, returns 1, otherwise it is not returned.

Chestnuts:

$arr = Array (1);

echo Is_array ($arr); 1;

$num = 5;

echo Is_int ($num); 1;

Var_dump ();

Gets the details of the variable's value and type.

Chestnuts

$str = ' Hello ';

echo Var_dump ($STR);//String (5) "Hello"

$arr = Array (' A ', ' B ', ' C ');

echo Dump ($arr); Array (3) {[0] = = string (1) "A" [1] = string (1) "B" [2] = = string (1) "C"}

Well, some knowledge of PHP is simple introduction to this, follow-up will be updated gradually. Thank you for your reading. If you have any suggestions, thank you for your comments.

  • 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.