Belki de sizin sorunuzu anlayamadım; bu durumda, ne olsun bir örnek sağlayabilir, ve ne beklediğiniz?
Are you sure it will try to load the functions from myfile.php
in the foo
namespace ?
Ben bir dosya var düşünürsek (temp-2.php) bu gibi görünüyor:
<?php
namespace foo;
function my_function_this_file() {
var_dump(__FUNCTION__);
}
my_function_this_file();
include 'my_other_file.php';
my_function_the_other_file();
Ve başka bir * (my_other_file.php) * böyle görünüyor:
<?php
function my_function_the_other_file() {
var_dump(__FUNCTION__);
}
Ben benim tarayıcıdan ilk aradığınızda, ben bu çıktıyı alıyorum:
string 'foo\my_function_this_file' (length=25)
string 'my_function_the_other_file' (length=26)
Herhangi bir ad beyan değil gerçeğine karşılık - Bu ikinci fonksiyon küresel hariç, herhangi bir isim alanı içinde değildir işaret gibi görünüyor.
Eğer doğru hatırlıyorsam, "ad" talimat sadece kullanılan dosya için geçerli değil, dahil dosyaları içindir.
namespaces FAQ den Import names cannot conflict with classes defined in the same file sayfa olduğunu da belirtmek gibi görünüyor.
Hope this helps, and I understood the question correctly...
EDIT: btw, bu gibi hatları sırasını takas:
<?php
include 'my_other_file.php';
namespace foo;
Işe yaramaz: "ad" talimat dosyasının ilk biri olmalıdır: Bunu yaparsanız, bir Ölümcül hata alırsınız:
Fatal error: Namespace declaration statement has to be the very first statement in the script