W3school PHP Tutorial Refining (a) PHP Basics _php Tutorial

Source: Internet
Author: User
Tags php basics
This note only extracts the parts of PHP that need to be noticed, about operators, simple judgments, and so on.

1 string

1.1 strlen () function to calculate the length of a string

1.2 strops () function to retrieve strings or characters within a string

2 arrays

2.1 Array of numeric IDs with numeric ID keys

Auto-Assign ID key:

$names = Array ("A", "B", "C"); Manually assign ID key:

$names [0] = "a"; $names [1] = "B"; $names [2] = "C"; Use the ID key:

2.2 Each ID key in an associative array array is associated with a value

To assign a value as a key:

$ages = Array ("A" =>10, "B" =>20, "C" =>30), another method:

$ages ["a"] = "ten", $ages ["b"] = "a", $ages ["c"] = "30"; Use the ID key:

2.3 A multi-dimensional array containing an array of one or more arrays (slightly)

3 Cycles

3.1 While

"$i + +;}?" >

3.2 Do...while

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

3.3 for

";}? >

3.4 foreach

The foreach statement is used to iterate through an array, and each time a loop is made, the value of the current array element is assigned to the value variable (the array pointer is moved one after the other) and so on.

Grammar

foreach (array as value) {//...} Example: outputting the value of a given array

";}? >

4 functions

4.1 Passing 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 the form from the method= "post".

5.1 $_get Variable

form.php

welcome.php

Welcome .
You are years old!

5.2 $_post Variable

What is different from $_get is that:

$_post does not send information limits, while $_get limits 100 characters

$_post does not reflect the value in the form at the URL, and the URL passed by $_get can be added to the Favorites folder

5.3 $_request Variable

The $_request variable can be used to obtain results sent to form data via the Get and post methods

http://www.bkjia.com/PHPjc/478822.html www.bkjia.com true http://www.bkjia.com/PHPjc/478822.html techarticle This note only extracts the parts of PHP that need to be noticed, about operators, simple judgments, and so on. 1 String 1.1 strlen () function calculates the 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.