<!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>Global space</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.namespaces.importing.html">Using namespaces: Aliasing/Importing</a></div> <div class="next" style="text-align: right; float: right;"><a href="language.namespaces.fallback.html">Using namespaces: fallback to global function/constant</a></div> <div class="up"><a href="language.namespaces.html">Namespaces</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="language.namespaces.global" class="sect1"> <h2 class="title">Global space</h2> <p class="verinfo">(PHP 5 >= 5.3.0)</p> <p class="para"> Without any namespace definition, all class and function definitions are placed into the global space - as it was in PHP before namespaces were supported. Prefixing a name with <em>\</em> will specify that the name is required from the global space even in the context of the namespace. <div class="example" id="example-254"> <p><strong>Example #1 Using global space specification</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #007700">namespace </span><span style="color: #0000BB">A</span><span style="color: #007700">\</span><span style="color: #0000BB">B</span><span style="color: #007700">\</span><span style="color: #0000BB">C</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* This function is A\B\C\fopen */<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">fopen</span><span style="color: #007700">() { <br /> </span><span style="color: #FF8000">/* ... */<br /> </span><span style="color: #0000BB">$f </span><span style="color: #007700">= \</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(...); </span><span style="color: #FF8000">// call global fopen<br /> </span><span style="color: #007700">return </span><span style="color: #0000BB">$f</span><span style="color: #007700">;<br />} <br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.namespaces.importing.html">Using namespaces: Aliasing/Importing</a></div> <div class="next" style="text-align: right; float: right;"><a href="language.namespaces.fallback.html">Using namespaces: fallback to global function/constant</a></div> <div class="up"><a href="language.namespaces.html">Namespaces</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>