par
Sékiltoyai » 16 avr. 2008, 14:53
Bonjour,
J'ai une petite question sur les namespaces à ceux qui connaissent bien les hautes sphères du PHP.
Dans le manuel, on peut lire :
Inside namespace (say A::B), calls to unqualified functions that are not defined in current namespace are resolved at run-time. Here is how a call to function foo() is resolved:
It looks for a function from the current namespace: A::B::foo().
It tries to find and call the internal function foo().
To call a user defined function in the global namespace, ::foo() has to be used.
Inside namespace (say A::B), calls to unqualified class names are resolved at run-time. Here is how a call to new C() is resolved:
It looks for a class from the current namespace: A::B::C.
It tries to find and call the internal class C.
It attemts to autoload A::B::C.
To reference a user defined class in the global namespace, new ::C() has to be used.
J'ai du mal à comprendre pourquoi une fonction inexistante n'est pas cherchée automatiquement dans le namespace. Y a-t-il une explication technique ou conceptuelle pour justifier ce choix que je trouve plutôt étonnant ?
Merci

Bonjour,
J'ai une petite question sur les namespaces à ceux qui connaissent bien les hautes sphères du PHP.
Dans le manuel, on peut lire :
[quote="php.net"]Inside namespace (say A::B), calls to unqualified functions that are not defined in current namespace are resolved at run-time. Here is how a call to function foo() is resolved:
It looks for a function from the current namespace: A::B::foo().
It tries to find and call the internal function foo().
To call a user defined function in the global namespace, ::foo() has to be used.
Inside namespace (say A::B), calls to unqualified class names are resolved at run-time. Here is how a call to new C() is resolved:
It looks for a class from the current namespace: A::B::C.
It tries to find and call the internal class C.
It attemts to autoload A::B::C.
To reference a user defined class in the global namespace, new ::C() has to be used.[/quote]
J'ai du mal à comprendre pourquoi une fonction inexistante n'est pas cherchée automatiquement dans le namespace. Y a-t-il une explication technique ou conceptuelle pour justifier ce choix que je trouve plutôt étonnant ?
Merci :)