PHP mutable variables, pre-defined variables, overview, $_get arrays

Source: Internet
Author: User

variable Variable

The so-called mutable variable is the name of a variable and a variable.

The syntax for mutable variables is a very special syntax for PHP--rare in other languages.


$v 1 = "abc"; This is a string variable whose content is the string "abc"

$ABC = 10; This is an ordinary variable whose content is the number 10

echo $ $v 1; At this point, the so-called "mutable variable"


How to understand mutable variables

1, when the $ symbol appears, it is possible to understand that it is a variable

2, where the first "$" appears, PHP interprets the view as a variable variable named #v1

3, we also know that the value of $v 1 is "abc"

4, then, the variable name after the first "$" symbol, which is naturally the number 10

5, that is, ECHO is trying to output a variable $abc, which is naturally the number 10


Pre-defined variables


Review:

1: Pre-defined variables are also called super Global variables, including: $_get, $_post, $_server, $_request, $GLOBALS, $_cookie, $_session .... (approx. 10)

2: Scope issues

In PHP, the scope of a custom variable is divided into two categories: global scope (outside the function), local scope (inside the function).

But the scope of a predefined variable is called a "hyper global scope": the global scope + the sum of local scopes (available inside and outside the function).

3: Data type issues

Super global variables are arrays!


$_get variable (array):

The word get is often present here: <form action= "abc.php" method= "Get" >.....</form>

This is called "form to submit data in a get Way"

The $_get is the predefined array variable, which refers to the collection (array) of all data submitted in this manner.

The data can also be submitted as a post.

In fact, in a Web page, there are several forms of submitting data in a get way:


Form one:

<form action= "abc.php" method= "Get" >

Project 1: <input type= "text name=" UName "/>

Project 2: <input type= "password" name= "upswd"/>

<input type= "Submit" value= "Submit"/>

</form>

Its function is: The user fills in the form data, and submits, will send the data (submits) to the page abc.php, actually also can understand to tear the webpage (abc.php), also can understand as "requests this webpage" (abc.php).


Form two:

<a href= "abc.php?uname=test1&upswd=123" >here is text...</a>

The role is: After users click on the link, the data will be sent (submitted) to the page abc.php, in fact, it can be understood to tear the page (abc.php), but also can be understood as "request this page" (abc.php). This request is also a GET request.


Form three:

<script>

location.href=abc.php?uname=test1&upswd=123; Using the property href of the Location object

</script>

The function is: When the line statement execution (usually in the function), the data will be sent (submitted) to the page abc.php, in fact, it can be understood to rip the page (abc.php), but also can be understood as "request the page" (abc.php). This request is also a GET request.


Form Four:

Script>

Location.assign ("abc.php?uname=test1&upswd=123"); The method of using the Location object assign ();

</script>

The function is: When the line statement execution (usually in the function), the data will be sent (submitted) to the page abc.php, in fact, it can be understood to rip the page (abc.php), but also can be understood as "request the page" (abc.php). This request is also a GET request.


Regardless of which form of get is submitted to the data, the fetch data is the same,

In the abc.php Web page

<?php

$v 1 = $_get[' uName '); Single quotes can also be double quotes, essentially a string, which is actually the key name of the array (subscript)

$v 2 = $_get[' upswd '); The key name must be exactly the same as the name at the time of submission and is case-sensitive

?>


Case:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/75/B5/wKioL1ZA0_aTdH97AABu0ghRGA4855.png "title=" 01.png "alt=" Wkiol1za0_atdh97aabu0ghrga4855.png "/>

Note: The name in the Hobby multi box needs to be written in the form of an array!

PHP mutable variables, pre-defined variables, overview, $_get arrays

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.