note 129931 added to language.references.whatare

From: Date: Sun, 22 Dec 2024 02:18:47 +0000
Subject: note 129931 added to language.references.whatare
Groups: php.notes 
Request: Send a blank email to php-notes+get-221738@lists.php.net to get a copy of this message
A reference allows you to create an alias for a variable. This means that when you assign a variable by reference, both variables point to the same data in memory. Any changes made to one variable will affect the other. Why Use References? Memory Efficiency: Instead of copying large data structures, you can reference them. Shared State: You can have multiple variables that reflect the same data, which can be useful in certain scenarios. $a = 10; // $a is assigned the value 10 $b = &$a; // $b is a reference to $a echo $a; // Outputs: 10 echo $b; // Outputs: 10 $b = 20; // Change the value of $b echo $a; // Outputs: 20 (because $b is a reference to $a) echo $b; // Outputs: 20 When we change $b, it also changes $a because they both point to the same value in memory. ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 103.18.14.135) ---- Manual Page -- https://php.net/manual/en/language.references.whatare.php Edit -- https://main.php.net/note/edit/129931 Del: integrated -- https://main.php.net/note/delete/129931/integrated Del: useless -- https://main.php.net/note/delete/129931/useless Del: bad code -- https://main.php.net/note/delete/129931/bad+code Del: spam -- https://main.php.net/note/delete/129931/spam Del: non-english -- https://main.php.net/note/delete/129931/non-english Del: in docs -- https://main.php.net/note/delete/129931/in+docs Del: other reasons-- https://main.php.net/note/delete/129931 Reject -- https://main.php.net/note/reject/129931 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221738) next »