End syntax for unbracketed namespace (to mix with bracketed namespace)












1














As we know, we can't use/mix namespaces in a single file like this:



namespace A;
...
...
namespace B{
...
}


does there exist any end syntax for unbracketed namespace, so it would become available to mix two namespaces? (like it's endif; for unbracketed if) ?



p.s. please, don't suggest to use brackets, I know that already (hence, my question is not "how to mix two namespaces in single file"). but my question is what I ask - if there is an end syntax for unbracketed NS.










share|improve this question
























  • I would like to emphasise the comment in the answer However is strongly not recommended to declare two namespaces inside same php script
    – Nigel Ren
    Nov 18 '18 at 8:12






  • 1




    No, it's not possible. Hence the fatal error Cannot mix bracketed namespace declarations with unbracketed namespace declarations...
    – revo
    Nov 18 '18 at 8:13










  • @NigelRen are you sure that this is a duplicate question? please, re-read it -it is different.
    – T.Todua
    Nov 18 '18 at 8:16












  • I flagged the dupe as that is how is has to be done AFAIK. If you want me to remove it and see if anyone can come up with something else then I will. It would probably help if you added a specific use case so that it would explain why you want to do this to make the context clearer (IMHO).
    – Nigel Ren
    Nov 18 '18 at 8:22










  • The dupe I flagged was stackoverflow.com/questions/22606792/…, but see if anything else comes up.
    – Nigel Ren
    Nov 18 '18 at 8:24
















1














As we know, we can't use/mix namespaces in a single file like this:



namespace A;
...
...
namespace B{
...
}


does there exist any end syntax for unbracketed namespace, so it would become available to mix two namespaces? (like it's endif; for unbracketed if) ?



p.s. please, don't suggest to use brackets, I know that already (hence, my question is not "how to mix two namespaces in single file"). but my question is what I ask - if there is an end syntax for unbracketed NS.










share|improve this question
























  • I would like to emphasise the comment in the answer However is strongly not recommended to declare two namespaces inside same php script
    – Nigel Ren
    Nov 18 '18 at 8:12






  • 1




    No, it's not possible. Hence the fatal error Cannot mix bracketed namespace declarations with unbracketed namespace declarations...
    – revo
    Nov 18 '18 at 8:13










  • @NigelRen are you sure that this is a duplicate question? please, re-read it -it is different.
    – T.Todua
    Nov 18 '18 at 8:16












  • I flagged the dupe as that is how is has to be done AFAIK. If you want me to remove it and see if anyone can come up with something else then I will. It would probably help if you added a specific use case so that it would explain why you want to do this to make the context clearer (IMHO).
    – Nigel Ren
    Nov 18 '18 at 8:22










  • The dupe I flagged was stackoverflow.com/questions/22606792/…, but see if anything else comes up.
    – Nigel Ren
    Nov 18 '18 at 8:24














1












1








1







As we know, we can't use/mix namespaces in a single file like this:



namespace A;
...
...
namespace B{
...
}


does there exist any end syntax for unbracketed namespace, so it would become available to mix two namespaces? (like it's endif; for unbracketed if) ?



p.s. please, don't suggest to use brackets, I know that already (hence, my question is not "how to mix two namespaces in single file"). but my question is what I ask - if there is an end syntax for unbracketed NS.










share|improve this question















As we know, we can't use/mix namespaces in a single file like this:



namespace A;
...
...
namespace B{
...
}


does there exist any end syntax for unbracketed namespace, so it would become available to mix two namespaces? (like it's endif; for unbracketed if) ?



p.s. please, don't suggest to use brackets, I know that already (hence, my question is not "how to mix two namespaces in single file"). but my question is what I ask - if there is an end syntax for unbracketed NS.







php namespaces






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 '18 at 8:15







T.Todua

















asked Nov 18 '18 at 8:02









T.ToduaT.Todua

29.8k12132130




29.8k12132130












  • I would like to emphasise the comment in the answer However is strongly not recommended to declare two namespaces inside same php script
    – Nigel Ren
    Nov 18 '18 at 8:12






  • 1




    No, it's not possible. Hence the fatal error Cannot mix bracketed namespace declarations with unbracketed namespace declarations...
    – revo
    Nov 18 '18 at 8:13










  • @NigelRen are you sure that this is a duplicate question? please, re-read it -it is different.
    – T.Todua
    Nov 18 '18 at 8:16












  • I flagged the dupe as that is how is has to be done AFAIK. If you want me to remove it and see if anyone can come up with something else then I will. It would probably help if you added a specific use case so that it would explain why you want to do this to make the context clearer (IMHO).
    – Nigel Ren
    Nov 18 '18 at 8:22










  • The dupe I flagged was stackoverflow.com/questions/22606792/…, but see if anything else comes up.
    – Nigel Ren
    Nov 18 '18 at 8:24


















  • I would like to emphasise the comment in the answer However is strongly not recommended to declare two namespaces inside same php script
    – Nigel Ren
    Nov 18 '18 at 8:12






  • 1




    No, it's not possible. Hence the fatal error Cannot mix bracketed namespace declarations with unbracketed namespace declarations...
    – revo
    Nov 18 '18 at 8:13










  • @NigelRen are you sure that this is a duplicate question? please, re-read it -it is different.
    – T.Todua
    Nov 18 '18 at 8:16












  • I flagged the dupe as that is how is has to be done AFAIK. If you want me to remove it and see if anyone can come up with something else then I will. It would probably help if you added a specific use case so that it would explain why you want to do this to make the context clearer (IMHO).
    – Nigel Ren
    Nov 18 '18 at 8:22










  • The dupe I flagged was stackoverflow.com/questions/22606792/…, but see if anything else comes up.
    – Nigel Ren
    Nov 18 '18 at 8:24
















I would like to emphasise the comment in the answer However is strongly not recommended to declare two namespaces inside same php script
– Nigel Ren
Nov 18 '18 at 8:12




I would like to emphasise the comment in the answer However is strongly not recommended to declare two namespaces inside same php script
– Nigel Ren
Nov 18 '18 at 8:12




1




1




No, it's not possible. Hence the fatal error Cannot mix bracketed namespace declarations with unbracketed namespace declarations...
– revo
Nov 18 '18 at 8:13




No, it's not possible. Hence the fatal error Cannot mix bracketed namespace declarations with unbracketed namespace declarations...
– revo
Nov 18 '18 at 8:13












@NigelRen are you sure that this is a duplicate question? please, re-read it -it is different.
– T.Todua
Nov 18 '18 at 8:16






@NigelRen are you sure that this is a duplicate question? please, re-read it -it is different.
– T.Todua
Nov 18 '18 at 8:16














I flagged the dupe as that is how is has to be done AFAIK. If you want me to remove it and see if anyone can come up with something else then I will. It would probably help if you added a specific use case so that it would explain why you want to do this to make the context clearer (IMHO).
– Nigel Ren
Nov 18 '18 at 8:22




I flagged the dupe as that is how is has to be done AFAIK. If you want me to remove it and see if anyone can come up with something else then I will. It would probably help if you added a specific use case so that it would explain why you want to do this to make the context clearer (IMHO).
– Nigel Ren
Nov 18 '18 at 8:22












The dupe I flagged was stackoverflow.com/questions/22606792/…, but see if anything else comes up.
– Nigel Ren
Nov 18 '18 at 8:24




The dupe I flagged was stackoverflow.com/questions/22606792/…, but see if anything else comes up.
– Nigel Ren
Nov 18 '18 at 8:24












1 Answer
1






active

oldest

votes


















1














There is no alternative syntax and endnamespace keyword, because there is no real need for it.



Using multiple namespaces in one file is a bad practice and should be avoided anyway, so one way to do this is more than enough. if and endif (and similar) was designed for using in templates since it increase readability when you mix HTML and PHP code. But views does not need to use namespaces at all, thus there is no pointless endnamespace tag. Using brackets is the only way to mix two namespaces in one file*.



* I don't count some ugly hacks like using eval().






share|improve this answer





















  • I don't agree with there is no real need for it. If there exists {} for namespaces, to define its start and end, then that means there is a need to end the namespace. and if the namespaces can be declared with two different methods, both of them should have the endings.
    – T.Todua
    Nov 18 '18 at 16:37












  • @T.Todua You have two ways of declaring namespace: file-level (declares namespace for the whole file content) and custom-scope-level (declares namespace for content inside of {} brackets). You don't need custom tag to end file-level namespace, because end of file is natural end for this scope.
    – rob006
    Nov 18 '18 at 17:34











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53358958%2fend-syntax-for-unbracketed-namespace-to-mix-with-bracketed-namespace%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














There is no alternative syntax and endnamespace keyword, because there is no real need for it.



Using multiple namespaces in one file is a bad practice and should be avoided anyway, so one way to do this is more than enough. if and endif (and similar) was designed for using in templates since it increase readability when you mix HTML and PHP code. But views does not need to use namespaces at all, thus there is no pointless endnamespace tag. Using brackets is the only way to mix two namespaces in one file*.



* I don't count some ugly hacks like using eval().






share|improve this answer





















  • I don't agree with there is no real need for it. If there exists {} for namespaces, to define its start and end, then that means there is a need to end the namespace. and if the namespaces can be declared with two different methods, both of them should have the endings.
    – T.Todua
    Nov 18 '18 at 16:37












  • @T.Todua You have two ways of declaring namespace: file-level (declares namespace for the whole file content) and custom-scope-level (declares namespace for content inside of {} brackets). You don't need custom tag to end file-level namespace, because end of file is natural end for this scope.
    – rob006
    Nov 18 '18 at 17:34
















1














There is no alternative syntax and endnamespace keyword, because there is no real need for it.



Using multiple namespaces in one file is a bad practice and should be avoided anyway, so one way to do this is more than enough. if and endif (and similar) was designed for using in templates since it increase readability when you mix HTML and PHP code. But views does not need to use namespaces at all, thus there is no pointless endnamespace tag. Using brackets is the only way to mix two namespaces in one file*.



* I don't count some ugly hacks like using eval().






share|improve this answer





















  • I don't agree with there is no real need for it. If there exists {} for namespaces, to define its start and end, then that means there is a need to end the namespace. and if the namespaces can be declared with two different methods, both of them should have the endings.
    – T.Todua
    Nov 18 '18 at 16:37












  • @T.Todua You have two ways of declaring namespace: file-level (declares namespace for the whole file content) and custom-scope-level (declares namespace for content inside of {} brackets). You don't need custom tag to end file-level namespace, because end of file is natural end for this scope.
    – rob006
    Nov 18 '18 at 17:34














1












1








1






There is no alternative syntax and endnamespace keyword, because there is no real need for it.



Using multiple namespaces in one file is a bad practice and should be avoided anyway, so one way to do this is more than enough. if and endif (and similar) was designed for using in templates since it increase readability when you mix HTML and PHP code. But views does not need to use namespaces at all, thus there is no pointless endnamespace tag. Using brackets is the only way to mix two namespaces in one file*.



* I don't count some ugly hacks like using eval().






share|improve this answer












There is no alternative syntax and endnamespace keyword, because there is no real need for it.



Using multiple namespaces in one file is a bad practice and should be avoided anyway, so one way to do this is more than enough. if and endif (and similar) was designed for using in templates since it increase readability when you mix HTML and PHP code. But views does not need to use namespaces at all, thus there is no pointless endnamespace tag. Using brackets is the only way to mix two namespaces in one file*.



* I don't count some ugly hacks like using eval().







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 18 '18 at 11:25









rob006rob006

9,1843932




9,1843932












  • I don't agree with there is no real need for it. If there exists {} for namespaces, to define its start and end, then that means there is a need to end the namespace. and if the namespaces can be declared with two different methods, both of them should have the endings.
    – T.Todua
    Nov 18 '18 at 16:37












  • @T.Todua You have two ways of declaring namespace: file-level (declares namespace for the whole file content) and custom-scope-level (declares namespace for content inside of {} brackets). You don't need custom tag to end file-level namespace, because end of file is natural end for this scope.
    – rob006
    Nov 18 '18 at 17:34


















  • I don't agree with there is no real need for it. If there exists {} for namespaces, to define its start and end, then that means there is a need to end the namespace. and if the namespaces can be declared with two different methods, both of them should have the endings.
    – T.Todua
    Nov 18 '18 at 16:37












  • @T.Todua You have two ways of declaring namespace: file-level (declares namespace for the whole file content) and custom-scope-level (declares namespace for content inside of {} brackets). You don't need custom tag to end file-level namespace, because end of file is natural end for this scope.
    – rob006
    Nov 18 '18 at 17:34
















I don't agree with there is no real need for it. If there exists {} for namespaces, to define its start and end, then that means there is a need to end the namespace. and if the namespaces can be declared with two different methods, both of them should have the endings.
– T.Todua
Nov 18 '18 at 16:37






I don't agree with there is no real need for it. If there exists {} for namespaces, to define its start and end, then that means there is a need to end the namespace. and if the namespaces can be declared with two different methods, both of them should have the endings.
– T.Todua
Nov 18 '18 at 16:37














@T.Todua You have two ways of declaring namespace: file-level (declares namespace for the whole file content) and custom-scope-level (declares namespace for content inside of {} brackets). You don't need custom tag to end file-level namespace, because end of file is natural end for this scope.
– rob006
Nov 18 '18 at 17:34




@T.Todua You have two ways of declaring namespace: file-level (declares namespace for the whole file content) and custom-scope-level (declares namespace for content inside of {} brackets). You don't need custom tag to end file-level namespace, because end of file is natural end for this scope.
– rob006
Nov 18 '18 at 17:34


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53358958%2fend-syntax-for-unbracketed-namespace-to-mix-with-bracketed-namespace%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?