I know, that the first line in PHP Files is because of security reasons. I read it here: https://docs.joomla.org/Why_do_most_of_the_Joomla!_PHP_files_start_with_defined(%27_JEXEC%27)%3F

But in the Joomla Core Code I find different commands. For example:

\defined('JPATH_PLATFORM') or die;,

\defined('JPATH_BASE') or die;


\defined('_JEXEC') or die;

Which line should PHP files in Joomla start with?


1 Answer 1


It makes no difference when used in extensions. But if you want to be technically correct, _JEXEC is the one to use. It's declared earliest, in the entry point file (i.e. index.php), and its sole purpose is for performing this entry point check. Other global constants may generally work but it's not really their purpose.

Also, JPATH_PLATFORM is deprecated as of 4.4 so definitely don't use that.

Your Answer

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

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