Cache
1 day ago
DBPermissions.php
1 day ago
DataEncoder.php
1 day ago
DatabaseOptions.php
1 day ago
Env.php
1 day ago
Escape.php
1 day ago
Glob.php
1 day ago
Hooks.php
1 day ago
Math.php
1 day ago
PluginInfo.php
1 day ago
Sanitize.php
1 day ago
ServerVars.php
1 day ago
SlashMode.php
1 day ago
Strings.php
1 day ago
Times.php
1 day ago
Urls.php
1 day ago
Version.php
1 day ago
WpDefaultDirectories.php
1 day ago
Env.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Framework\Utils; |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | class Env |
| 16 | { |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | public static function get(string $name) |
| 23 | { |
| 24 | |
| 25 | |
| 26 | if (function_exists('getenv')) { |
| 27 | $value = getenv($name); |
| 28 | if (is_string($value)) { |
| 29 | return $value; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | foreach ([$_SERVER, $_ENV] as $source) { |
| 34 | if (isset($source[$name]) && is_scalar($source[$name])) { |
| 35 | return (string)$source[$name]; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | return false; |
| 40 | } |
| 41 | } |
| 42 |