note 126294 added to language.references.whatdo

From: Date: Sat, 31 Jul 2021 04:11:01 +0000
Subject: note 126294 added to language.references.whatdo
Groups: php.notes 
Request: Send a blank email to php-notes+get-216694@lists.php.net to get a copy of this message
It matters if you are playing with a reference or with a value Here we are working with values so working on a reference updates original variable too; $a = 1; $c = 22; $b = & $a; echo "$a, $b"; //Output: 1, 1 $b++; echo "$a, $b";//Output: 2, 2 both values are updated $b = 10; echo "$a, $b";//Output: 10, 10 both values are updated $b =$c; //This assigns value 2 to $b which also updates $a echo "$a, $b";//Output: 22, 22 But, if instead of $b=$c you do $b = &$c; //Only value of $b is updated, $a still points to 10, $b serves now reference to variable $c echo "$a, $b"//Output: 10, 22 ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 103.167.232.89) ---- Manual Page -- https://php.net/manual/en/language.references.whatdo.php Edit -- https://main.php.net/note/edit/126294 Del: integrated -- https://main.php.net/note/delete/126294/integrated Del: useless -- https://main.php.net/note/delete/126294/useless Del: bad code -- https://main.php.net/note/delete/126294/bad+code Del: spam -- https://main.php.net/note/delete/126294/spam Del: non-english -- https://main.php.net/note/delete/126294/non-english Del: in docs -- https://main.php.net/note/delete/126294/in+docs Del: other reasons-- https://main.php.net/note/delete/126294 Reject -- https://main.php.net/note/reject/126294 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216694) next »