Config::get (method)

Last updated: Sat, Apr 15, 2023 6:49 pm
Return to Knowledgebase

Purpose

Retrieves a configuration value from the $GLOBALS['config'] array.

Location

users/classes/Config.php

Parameters

# Parameter Data Type Required Description
1 $path string No A string that represents the path to the configuration value that you want to retrieve.

Returns

Data Type Description of Returned Data
string The method iteratively accesses each key in the array until it finds the final value. If any of the keys in the path are not found, the method returns false.

Example

Config::get('mysql/username');

Further Documentation:

This is primarily used internally, but there may be times that you want to return configuration info such as needing to connect another service to your database.
$dbuser = Config::get('mysql/username');

will grab your database username from the init.php file.

The get method takes one optional parameter, $path, which is a string that represents the path to the configuration value that you want to retrieve. The get method uses this path to navigate through the $GLOBALS['config'] array to find the desired value.

The $path string is divided into parts using the forward slash (/) character as a separator. Each part represents a key in a nested array. The method iteratively accesses each key in the array until it finds the final value. If any of the keys in the path are not found, the method returns false.