X-Cart:Global object variables

From X-Cart 4 Classic
Jump to: navigation, search

(v4.4) When X-Cart starts up it runs index.php which then includes top.inc.php and init.php. These two files set most of the global values needed to run the rest of X-Cart's code.

Some of the notable globals set are:

  • $xcart_dir - The top level directory of the X-Cart installation (The directory containing top.inc.php).
  • $config - An array of the values from the xcart_config table in the database.
  • $sql_tbl - An array of all of the aliases of the X-Cart database table names. For example the xcart_config

Also included are the $xcart_dir/config.php and if present the $xcart_dir/config.local.php (for your custom config values).

init.php will also load the database functions, log into the database and establish a database connection.

If you are building a command line app to run within the X-Cart framework you can do this with the following PHP code:

$topDir = <xcart directory>;
require_once "$topDir/top.inc.php";
require_once "$xcart_dir/init.php";

By adding a "print_r ($GLOBALS);" line you can see all the globals that are created at this point.