35 lines
791 B
PHP
35 lines
791 B
PHP
<?php
|
|
/**
|
|
* Global Helper Functions
|
|
*/
|
|
|
|
if (!function_exists('env')) {
|
|
function env(string $key, $default = null) {
|
|
return $_ENV[$key] ?? $default;
|
|
}
|
|
}
|
|
|
|
if (!function_exists('input')) {
|
|
function input(string $key = null, $default = null) {
|
|
static $inputData = null;
|
|
if ($inputData === null) {
|
|
$json = file_get_contents('php://input');
|
|
$inputData = array_merge($_GET, $_POST, json_decode($json, true) ?? []);
|
|
}
|
|
|
|
if ($key === null) return $inputData;
|
|
return $inputData[$key] ?? $default;
|
|
}
|
|
}
|
|
|
|
if (!function_exists('dd')) {
|
|
function dd(...$vars) {
|
|
foreach ($vars as $v) {
|
|
echo "<pre>";
|
|
var_dump($v);
|
|
echo "</pre>";
|
|
}
|
|
die();
|
|
}
|
|
}
|