Every language has its way of dealing with things. If that was it, I do not even know if the question would make sense. In this case it is not only the syntax that is different, the semantics as well.
In PHP the definition holds for the whole file, until you find a new definition of namespace
. It should always be done at the beginning of the file. At least in this syntax.
Question in more detail .
Documentation about definition . About using multiple .
Wallace says in comment that it may be different, but I have not seen a reference on the subject. I hate languages that document wrong or confusing. And I just trust the documentation. Using something that works but is not documented is the last thing a programmer should do.
The keys also work in PHP.
Both C # and PHP can only have types as members of namespace
.
In C # the members of a determining namespace are inside the keys that delimit it. Therefore it is possible to have more than one namespace per file.
Question in more detail .
Documentation .
The correct C # syntax:
namespace Example {
class ExampleClass {...}
}
Do not put the class name, even less of the method in the name of namespace
.
If it were to have a multi level name it would look like this:
namespace Nome.OutroNome.MaisUmNome
But note that deep down this separation is virtual. The name is one thing. There is not a namespace
inside another. It is perfectly possible to have this namespace
without having Nome
. See question link above for more details.