(1) basic php knowledge and some notes _ PHP Tutorial

Source: Internet
Author: User
(1) basic php knowledge and some notes. (1) basic php knowledge and some notes: any program, including php, is running in the memory, and php code must be read to the memory before execution. [Php operation (1) basic php knowledge and some notes

Note: Any program, including php, is running in the memory. The php code must be read to the memory for execution.

[Php running mode]

1. it is called through a server (such as apache.

2. call through the command line (the server is not required because port 80 is not accessed ).

[Php start and end characters]

 

The php statement ends with a semicolon, but?> It can replace the semicolon that is closest to it because HTML and PHP are often mixed to write, omitting the semicolon, for example:

 

This code displays a user name input box, and the initial value of the input box is the value of the variable $ user.

[Php comments]

Php comments are similar to the C language. you can use // and # to comment a single line, and use/**/To comment multiple lines.

Popular php annotation standard: phpjavasentor style annotation.

/*** Summation function ** @ param $ p1 int number of append * @ param $ p2 int number of append ** @ return int sum */function func1 ($ p1, $ p2) {return $ p1 + $ p2 ;}

Note: Annotations only affect php code, but not HTML code (including plain text ).

Php code in html comments]

Multi-line comment If php code is nested in it, the php code is actually executed, but the generated html is commented out, so it is not displayed.

Tip: note this when using annotations. do not comment out php code like this.

[Php variable]

I. Overview

1. $ name = 'a'; // the variable name references the value. A variable contains three parts: namespace, value space, and reference space.

Reference refers to the relationship between variable names and variable values.

Tip: $ is not a part of the variable name, but is used to declare a variable behind it. variables and functions can be renamed. use the $ time table variable name, if $ is not used, it is used as the function name.

2. php variable names are case sensitive.

3. use var_dump ( <变量> ) Function can output the type and value of a variable.

4. use unset ( <变量> A function can delete a variable. deleting a variable only deletes the reference and variable name, but does not delete the value space. Php has its own garbage collection mechanism, which automatically releases the unreferenced value space.

II. Basic syntax

Value Transfer: $ a = $ B; // value transfer is a copy of the value space.

Transfer a reference: $ a = & $ B; // The transfer of a reference is a copy of the reference space. if you modify a, the value of B is also modified.

[GET and POST]

1. GET: send data to the server through the request URL.

Syntax: Script name? P1 = xx & p2 = xx & p3 = xx

Php GET data: Use the _ GET array.

2. POST: generally used for form submission.

Php obtains POST data through the _ POST array.

This is achieved by sending a data body to the server.

[GET and POST submission of simple forms]

Front end:

  

Backend:

 post:";    var_dump($_POST);?>

Tip: No matter whether it is POST or GET, the data will exist in the _ REQUEST variable. if both GET and POST appear, the value of _ POST is generally saved in _ REQUEST (which one can be modified according to the php configuration. in ini, request_order = "GP", GP indicates that GET is before POST, so you can rewrite GET data in POST ).

Http://www.bkjia.com/PHPjc/983563.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/983563.htmlTechArticle (1) basic knowledge of php and some notes Note: Any program, including php, is running in the memory, php code needs to be read to the memory for execution. [Php operation...

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.