mirror of
https://github.com/rekryt/iplist.git
synced 2025-10-13 08:59:34 +03:00
Initial commit
This commit is contained in:
33
src/functions.php
Normal file
33
src/functions.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace OpenCCK;
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return ?string
|
||||
*/
|
||||
function getEnv(string $key): ?string {
|
||||
if (!isset($_ENV[$key])) {
|
||||
return null;
|
||||
}
|
||||
if (preg_match('/^"(.*)"$/i', $_ENV[$key], $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
return $_ENV[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Debug function
|
||||
* @param mixed $mixed
|
||||
* @param bool $exit
|
||||
* @return void
|
||||
*/
|
||||
function dbg(mixed $mixed, bool $exit = true): void {
|
||||
if (php_sapi_name() == 'cli') {
|
||||
echo print_r($mixed, true);
|
||||
} else {
|
||||
echo '<pre>' . print_r($mixed, true) . '</pre>';
|
||||
}
|
||||
if ($exit) {
|
||||
exit();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user