Home  >  Article  >  Backend Development  >  W3school’s PHP tutorial extraction (1) PHP basics_PHP tutorial

W3school’s PHP tutorial extraction (1) PHP basics_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:43:29882browse

This note only extracts the parts of PHP that need attention, and does not write about operators, simple judgments, etc.

1 string

1.1 strlen() function calculates the string length

1.2 strops() function retrieves strings or characters within a string

2 array

2.1 Numeric array Array with numeric ID keys

Automatically assign ID key:

$names = array("a","b","c");Manually assign ID key:

$names[0] = "a";$names[1] = "b";$names[2] = "c";Use ID key:

2.2 Associative array Each ID key in the array is associated 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 ID key:

2.3 Multidimensional array An array containing one or more arrays (omitted)

3 loops

3.1 while

"$i++;}?>

3.2 do...while

";}while($i<5);?>

3.3 for

";}?>

3.4 foreach

The foreach statement is used to loop through the array. Each time the loop is performed, the value of the current array element will be assigned to the value variable (the array pointer will move one by one) and so on.

Grammar

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 values ​​from the form with method="get".

The $_POST variable is used to collect values ​​from the form with method="post".

5.1 $_GET variable

form.php

Name:Age:
welcome.php

Welcome .
You are years old!

5.2 $_POST variable

The difference from $_GET is:

$_POST has no limit on the amount of information sent, while $_GET is limited to 100 characters

$_POST does not reflect the value in the form at the url, but 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 the form data through the get and post methods

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478822.htmlTechArticleThis note only extracts the parts of PHP that need attention, and does not write about operators, simple judgments, etc. 1 String 1.1 The strlen() function calculates the length of the string ?phpecho strlen("hello world...
Statement:
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