php offers 2 syntax declaring namespaces. can use namespace no braces or braces seen below.
without braces
namespace foo/bar; class any{}
with braces
namespace foo/bar { class any{} }
is there difference in functionality or behavior of these 2 ways of using namespaces or both work/function same way?
there different reasons each case, there good example on php site.
the reason you'd use curly brackets around namespace if there multiple namespaces in 1 file or need have global non-namespaced code in same file code contained within namespace.
also if there multiple namespaces in 1 file, non-bracketed syntax allowed well.
as per php guidelines not recommended , if can, keep 1 namespace per file.
Comments
Post a Comment