downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

İsim alanlarının kullanımı: son çare olarak küresel işlev ve sabitler> <İsim alanlarının kullanımı: İthal/Rumuz
[edit] Last updated: Fri, 23 Mar 2012

view this page in

Küresel Alan

Herhangi bir isim alanı tanımı olmaksızın, tüm sınıf ve işlev tanımları PHP'de isim alanlarının desteklenmediği zamanlardaki gibi küresel alana yerleştirilir. Bir ismin önüne doğrudan doğruya \ konulması, bu ismin bir isim alanı bağlamında bile küresel alandan bir isim olarak işlem görmesini sağlar.

Örnek 1 - Küresel alan belirtiminin kullanımı

<?php
namespace A\B\C;

/* A\B\C\fopen işlevidir */
function fopen() {
     
/* ... */
     
$f = \fopen(...); // küresel fopen çağrılır
     
return $f;
}
?>



add a note add a note User Contributed Notes Küresel Alan
xmarcos at gmail dot com 21-May-2012 01:08
That's the expected behavior, you have to declare the namespace at the top of the file to "extend" it.

If you include a global namespaced file, it will operate on the global namespace.
routinet 28-Aug-2011 05:22
Included files will default to the global namespace.
<?php
//test.php
namespace test {
  include
'test1.inc';
  echo
'-',__NAMESPACE__,'-<br />';
}
?>

<?php
//test1.inc
 
echo '-',__NAMESPACE__,'-<br />';
?>

Results of test.php:

--
-test-

 
show source | credits | stats | sitemap | contact | advertising | mirror sites