W3school PHP Tutorial extraction (1) PHP Basics _ PHP Tutorial

Source: Internet
Author: User
Tags php basics
W3school PHP Tutorial (1) PHP Basics. This note only extracts the notes for php, and does not write any content about operators or simple judgments. 1 string 1.1 strlen () function compute string length? Phpechostrlen.

1 string

1.1 strlen () function compute string length

The 1.2 strops () function searches strings or characters in strings.

2 array

2.1 Numeric array with digit ID key

Auto-assigned ID key:

$ Names = array ("a", "B", "c"); manually allocate the ID key:

$ Names [0] = "a"; $ names [1] = "B"; $ names [2] = "c"; use the ID key:

2.2 Associate each ID key in the array with a value

Assign values as keys:

$ Ages = array ("a" => 10, "B" => 20, "c" => 30); another method:

$ Ages ["a"] = "10"; $ ages ["B"] = "20"; $ ages ["c"] = "30"; use the ID key:

2.3 Multi-dimensional arrays an array containing one or more arrays (omitted)

3 cycles

3.1 while

"$ I ++ ;}?>

3.2 do... while

";}While ($ I <5) ;?>

3.3

";}?>

3.4 foreach

The foreach statement is used to traverse the array cyclically. each time a loop is executed, the value of the current array element is assigned to the value variable (the array pointer is moved one by one), and so on.

Syntax

Foreach (array as value) {//...} example: output the value of the given array

";}?>

4 Functions

4.1 pass parameters

";}Echo" my name is "; writeName (" Gang "," Li "); echo" my name is "writeName (" San "," Zhang ");?>

4.2 Return value

5. form processing

The $ _ GET variable is used to collect the value of a form from method = "get.

The $ _ POST variable is used to collect the value of a form from method = "post.

5.1 $ _ GET variable

Form. php

Welcome. php

Welcome .
You are Years old!

5.2 $ _ POST variable

Unlike $ _ GET:

$ _ POST has no limit on the amount of sent information, while $ _ GET has a limit of 100 characters.

$ _ POST does not reflect the value in the form at the url, while the url passed by $ _ GET can be added to favorites.

5.3 $ _ REQUEST variable

The $ _ REQUEST variable can be used to obtain the results sent to form data through the get and post methods.

Bytes. 1 string 1.1 strlen () function compute string length? Phpecho strlen ("hello world...

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.