Warning: This page has not been updated in over over a year and may be outdated or deprecated.
legacy:vufind_1.x_developer_manual:global_variables
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
global_variables [2015/12/10 18:14] – [Primary Globals] demiankatz | legacy:vufind_1.x_developer_manual:global_variables [2018/12/19 14:20] (current) – demiankatz | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Global Variables ====== | ====== Global Variables ====== | ||
- | VuFind uses a few important global variables that you may find helpful when [[building a module|building modules]] and maintaining the code. | + | // As of release 2.0, VuFind no longer relies on global |
- | + | ||
- | ===== Primary Globals ===== | + | |
- | + | ||
- | These two globals are the most important, and their use is encouraged: | + | |
- | + | ||
- | * $configArray \\ This global contains the contents of the web/conf/config.ini file mapped into associative array format. | + | |
- | * $interface \\ This global is an instance | + | |
- | + | ||
- | ===== Secondary Globals ===== | + | |
- | + | ||
- | These globals are used in the code in a few places, but their use should be avoided unless absolutely necessary: | + | |
- | + | ||
- | * $translator \\ This global | + | |
- | * $user \\ This global is an object representing the current logged-in user, if one exists. | + | |
- | + | ||
- | ===== Accessing a Global ===== | + | |
- | + | ||
- | Remember that in PHP, you need to declare globals at the top of any functions or methods that use them. For example: | + | |
- | + | ||
- | <code php> | + | |
- | function dumpConfigArray() | + | |
- | { | + | |
- | global $configArray; | + | |
- | + | ||
- | print_r($configArray); | + | |
- | } | + | |
- | </code> | + | |
---- struct data ---- | ---- struct data ---- | ||
+ | properties.Page Owner : | ||
---- | ---- | ||
legacy/vufind_1.x_developer_manual/global_variables.txt · Last modified: 2018/12/19 14:20 by demiankatz