$ A = newA and $ a = & amp; newA are there any differences? $ A = newA; // $ a is a copy of newA's pointer ($ a stores the pointer itself) $ a = & amp; newA; // $ a is a reference to the newA pointer ($ a stores the pointer address). Is there any difference between the preceding statement $ A = new a and $ A = & new?
$ A = new A; // $ a is A copy of the pointer of new a ($ a stores the pointer itself)
$ A = & new A; // $ a is A reference to the pointer of new a ($ a stores the pointer address)
Are the above statements correct?
In addition:
$ C = & $ a, why does $ a become A pointer reference of?
------ Solution --------------------
$ C = & $ a, why does $ a become A pointer reference of?
Is followed by $ a = & new ;?
------ Solution --------------------
Hey, & in C, it's an access code.
------ Solution --------------------
All the variables in php are pointers, but for string, int, etc., the value = is the copy of the object. for the object, the value = is the copy of the address (that is, the reference ), I feel so understandable now.
------ Solution --------------------
Whatever version of php, the new operator generates references.
$ A = & new;
This writing method is not accurate. Assign an object reference to a variable?
Therefore, an error type is added in php5.3 to standardize the writing format.
Deprecated: Assigning the return value of new by reference is deprecated
Php5.2 and the past do not report errors, but it does not mean that it is not an error.
Just as if you have blocked E_NOTICE-level errors, but you can't say there is no error. after all, we still use undefined variables or subscripts.
------ Solution --------------------
Very tangled problem
------ Solution --------------------
Orthodox usage
$ C = new;
The other usage is nonsense.
------ Solution --------------------
Look at Niu Ren's blog.
Http://www.laruence.com/2008/09/19/520.html
Explained your issue on the 6th floor.
------ Solution --------------------
I checked the manual:
References:
Referencing in PHP means accessing the same variable content with different names. This is not like the pointer of C. Instead, the reference is the alias of the symbol table. Note that in PHP, the variable name and variable content are different, so the same content can have different names. The closest analogy is the Unix file name and the file itself-the variable name is a directory entry, while the variable content is the file itself. A reference can be considered as a hardlink in a Unix file system.
About new:
Construct an instance of "type" and store the reference to the object into "result ".
Therefore, $ c = new A; is A value reference instead of an object copy. $ C = & new A; is the incorrect method.
Since PHP 5, new automatically returns a reference. Therefore, when = & is used here, messages at the E_STRICT level will be generated.
------ Solution --------------------
Assignment:
Note that the value assignment operation copies the value of the original variable to the new variable (pass the value assignment), so changing one does not affect the other. This is also suitable for copying some values such as large arrays in intensive loops. You can also assign values by reference using the $ var = & $ othervar; syntax. Referencing a value assignment means that both variables point to the same data without any data copies. For more information about references, see references. In PHP 5, objects are always assigned by reference unless the new clone keyword is explicitly used.
PHP code
Foo = 2; echo "oa: $ oa-> foo, ob: $ ob-> foo \ n";?>
------ Solution --------------------
$ A = 1;
$ B = & $;
Different variables point to the same address. when one of the variables ($ B = 2) changes, the other variable changes ($ a = 2 ). but after $ B is destroyed (unset ($ B), $ a = 2 still exists.
$ A = 1;
$ B = $ a; // it is $ B = 1
>$ A = 1; $ B = 1;
$ B $ a has no relationship with a dime. you are me and you don't care about anyone.
$ A = & new A; I really don't need such things.