PHP learning notes -- variables in php

Source: Internet
Author: User

Variable in PHP (for more information, see the php manual ):

To put it bluntly, the variable in php parses the value of a variable into a variable name and reads the value of that variable name. Instance:

  

<? = "China";       = "a";            = "I'm Chinese !";      = "b";           ."<br />";       $."<br />";      = "f";       $."<br />";      = "b";      $."<br /><br />";          ."<br />";      $."<br />";      $$."<br /><br />";          ."<br />";      $."<br />";      $$."<br />";      $$$."<br /><br />";  = "China";      ."<br />";      $; ?>

Note: Variable variables cannot be applied to $ this and super global variables (the scope of php variables is different from that of other advanced programming languages. View code)

<? = 'man' = 'abc';     $$ = 'def' ."<br />";      ;          "<br /> 

 

Variable Functions:

<? "This is B" c (= "China") "this is" = 'B' (); = 'C'?>

 

 

 

A typical application of variable variables:

<! DOCTYPE html "-// W3C // dtd xhtml 1.0 Transitional // EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 

 

  Supplement:

Variable features. If a variable is not declared in advance, if you want to assign a value to a variable, a PHP operation in the background is that when you assign a value to this undeclared variable, the background has already affirmed this variable for you. Let's look at the example:

<? (-> Name )? "True": "false"). "--"-> = A ();-> show ();-> name = "I have output. This variable is declared! "" <Br/> "-> show ();?>

Summary: after reading the above example, you will see the code encapsulated by others. If there is a variable that is not declared, it will be used directly. Don't be surprised. You must set it yourself. You just need to assign values... (PS: In fact, I am also confused at the beginning, because I used to engage in. NET in C #, it is absolutely not allowed to happen. Strong languages are used... Looking at this weak type of language, it is not very suitable at the beginning)

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.