note 113092 added to language.references.whatdo
| From: | admin at torntech dot com | Date: | Wed, 28 Aug 2013 19:58:41 +0000 |
| Subject: | note 113092 added to language.references.whatdo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-196107@lists.php.net to get a copy of this message | ||
Something that has not been discussed so far is reference of a reference.
I needed a quick and dirty method of aliasing incorrect naming until a proper rewrite could be done.
Hope this saves someone else the time of testing since it was not covered in the Does/Are/Are Not
pages.
Far from best practice, but it worked.
<?php
$a = 0;
$b =& $a;
$a =& $b;
$a = 5;
echo $a . ', ' . $b;
//ouputs: 5,5
echo ' | ';
$b = 6;
echo $a . ',' . $b;
//outputs: 6,6
echo ' | ';
unset( $a );
echo $a . ', ' . $b;
//outputs: , 6
class Product {
public $id;
private $productid;
public function __construct( $id = null ) {
$this->id =& $this->productid;
$this->productid =& $this->id;
$this->id = $id;
}
public function getProductId() {
return $this->productid;
}
}
echo ' | ';
$Product = new Product( 1 );
echo $Product->id . ', ' . $Product->getProductId();
//outputs 1, 1
$Product->id = 2;
echo ' | ';
echo $Product->id . ', ' . $Product->getProductId();
//outputs 2, 2
$Product->id = null;
echo ' | ';
echo $Product->id . ', ' . $Product->getProductId();
//outouts ,
----
Server IP: 69.147.83.199
Probable Submitter: 50.79.80.225
----
Manual Page -- http://php.net/manual/en/language.references.whatdo.php
Edit -- https://master.php.net/note/edit/113092
Del: integrated -- https://master.php.net/note/delete/113092/integrated
Del: useless -- https://master.php.net/note/delete/113092/useless
Del: bad code -- https://master.php.net/note/delete/113092/bad+code
Del: spam -- https://master.php.net/note/delete/113092/spam
Del: non-english -- https://master.php.net/note/delete/113092/non-english
Del: in docs -- https://master.php.net/note/delete/113092/in+docs
Del: other reasons-- https://master.php.net/note/delete/113092
Reject -- https://master.php.net/note/reject/113092
Search -- https://master.php.net/manage/user-notes.php