-
Notifications
You must be signed in to change notification settings - Fork 0
$Leravel Variable
$Leravel Variable is designed to perform several important tasks necessary for the development of a PHP web application. It retrieves settings and language files, sets the current language based on the user's preferences, creates an array of server request data, and establishes a connection to a MySQL database if enabled.
$Leravel Variable first retrieves the contents of two JSON files: settings.json
and localization/[language].json
. It uses the file_get_contents()
function to read the contents of these files and the json_decode()
function to decode the JSON content into an associative array. The second argument in the json_decode()
function is set to true
to ensure the result is an associative array rather than an object.
$Leravel Variable checks the value of the leravel_lang
cookie to determine the user's preferred language. If the cookie is not set, it sets the default language specified in the settings.json
file. The code then retrieves the appropriate language file based on the language preference and sets it to the $Leravel["lang"]
variable.
$Leravel Variable an array of server request data by retrieving relevant data from the $_SERVER
, $_GET
, $_POST
, $_FILES
, $_COOKIE
, and $_SESSION
superglobal arrays. The resulting array is stored in the $Leravel["request"]
variable.
If the database
setting in the settings.json
file is enabled, $Leravel Variable establishes a connection to the MySQL database specified in the settings file using the Mysqli
class. The connection details are obtained from the settings.json
file, and the resulting connection object is stored in the $Leravel["conn"]
variable. If the connection fails, $Leravel Variable dies with an error message.
Made with ❤️ by leraticarimarka
Want to learn more about me? Check out my github page!