Methods for PHP reference operations and local static variables for external operation functions _php Tutorial

Source: Internet
Author: User

Methods for PHP reference operations and local static variables for external operation functions


A static variable inside an external manipulation function or member method by means of a reference

Here is a simple example of three questions about quoting:

1. A type conversion within a function after a parameter reference is also an address operation

2. Once the parameter is referenced and passed to another function, the reference must be added again to maintain the address operation

3. Function return value reference must add Reference operator at function declaration and call


This example uses the action of the object method, and the same applies to the function

 
  Test2 ($a); $i ++;var_dump ($a); Var_dump ($i); return $i;} protected function Test2 (& $a) {$a [' name '] = ' snail ';}} $obj = new A (); $a = "; $c = & $obj->test1 ($a); $c ++;var_dump ($a); $obj->test1 ($a); Var_dump ($a);


Results of the output







http://www.bkjia.com/PHPjc/859805.html www.bkjia.com true http://www.bkjia.com/PHPjc/859805.html techarticle The PHP reference operation and the method of the local static variable of the external operation function are referred to as a simple example under the static variables inside the external operation function or member method, stating ...

  • 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.