A general Joomla! coding question... Checking _JEXEC is defined.

In administrator/components/.../src/everywhere it is

defined('_JEXEC') or die;
use function defined;

Whereas in components/.../src/everywhere it's

\defined('_JEXEC') or die;

Is there a specific coding standard that we should use for Joomla! code?

1 Answer 1


I asked this on the Joomla! internal development chat and was told the second one is the optimised version currently in namespaced files.

Richard, a lead Joomla! developer wrote "Backslash makes it clear it is looked for in the global namespace so less risk for name conflict and also a small optimization".

Benjamin, another lead developer wrote "from 7.0+ it then uses opcodes, which is the optimization, so most likely you should go for it also in non-namespaced files"

  • ...I was hoping to coerce Benjamin to engage on this page. Regardless, thanks for posting it here.
    – mickmackusa
    Jan 20, 2022 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.