Forum
>
_JEXEC explained
Welcome, Guest

_JEXEC explained
Topic Normal _JEXEC explained
by guest on 01/20/2009 14:46

This constant is not really a "string" as much as it is a boolean value either being 1 or 0 (zero). This constant is used to check to see if Joomla! is calling the file, or if a person has directly typed the path to the file in the URL. Joomla! sets _JEXEC to 1 (or any positive value really) when it is the one calling the file. _JEXEC is normaly used to check to make sure that no direct access to the file is being used.

Echoing  _JEXEC will either return "nothing" ( no value at all if set to zero or null ) or else 1 if it has been set by Joomla ( or some other application). This constant is normaly used in components and other files like this:

defined( '_JEXEC' ) or die( 'Access Denied' );

Please understand that this is a security constant. You can ommit _JEXEC if you want to, but by doing so, you are making it very easy for a hacker to come in and simply access the file at their own will then do whatever they want with that file. Again, this constant is used to check and see if Joomla! is accessing the file, or if it is being "directly" accessed through the URL by typing the path to the file in the browser window.