<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Spotting References</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.references.unset.html">Unsetting References</a></div> <div class="next" style="text-align: right; float: right;"><a href="reserved.variables.html">Predefined Variables</a></div> <div class="up"><a href="language.references.html">References Explained</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="language.references.spot" class="sect1"> <h2 class="title">Spotting References</h2> <p class="simpara"> Many syntax constructs in PHP are implemented via referencing mechanisms, so everything mentioned herein about reference binding also applies to these constructs. Some constructs, like passing and returning by reference, are mentioned above. Other constructs that use references are: </p> <div class="sect2" id="references.global"> <h3 class="title">global References</h3> <p class="para"> When you declare a variable as <strong class="command">global $var</strong> you are in fact creating reference to a global variable. That means, this is the same as: <div class="informalexample"> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$var </span><span style="color: #007700">=& </span><span style="color: #0000BB">$GLOBALS</span><span style="color: #007700">[</span><span style="color: #DD0000">"var"</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> <p class="simpara"> This also means that unsetting <var class="varname"><var class="varname">$var</var></var> won't unset the global variable. </p> </div> <div class="sect2" id="references.this"> <h3 class="title"><em>$this</em></h3> <p class="simpara"> In an object method, <var class="varname"><var class="varname">$this</var></var> is always a reference to the caller object. </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.references.unset.html">Unsetting References</a></div> <div class="next" style="text-align: right; float: right;"><a href="reserved.variables.html">Predefined Variables</a></div> <div class="up"><a href="language.references.html">References Explained</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>