What to do

xiaoxiao2021-03-06  40

PHP's reference allows you to use two variables to point to the same content. Means, when you do this:

This means $ A and $ B point to the same variable. Note: $ A and $ B are exactly the same here, this is not $ A pointing to $ B or the opposite, but $ A and $ B point to the same place.

The same syntax can be used in a function, it returns a reference, and is used in the New operator (PHP 4.0.4 and later):

Note: A copy is generated without the use of & operators. If you use $ THIS in the class, it will act on the current instance of this class. There is no use of the assignment to copy this instance (eg object) and $ this will work on this copy, which does not always want the result. Due to performance and memory consumption, usually you just want to work on one instance.

Although you can use @ operators to close any error messages in the constructor, such as @new, but use the & new statement this doesn't work. This is a restriction of the Zend engine and will cause a parsing error.

The second thing to be cited is to deliver variables with reference. This is achieved by establishing a local variable in the function and the variable is implemented in the call range. E.g:

$ a = 5; foo ($ a);?>

The $ A will become 6. This is because the variable $ VAR in the foo function points to the same content points to $ a. See more detailed explanation.

Third things made by reference are references to return.

转载请注明原文地址:https://www.9cbs.com/read-68333.html

New Post(0)