PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.9.5
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.9.5
4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Framework / Utils / Env.php
wp-staging / Framework / Utils Last commit date
Cache 8 months ago DBPermissions.php 9 months ago DataEncoder.php 11 months ago DatabaseOptions.php 2 days ago Env.php 2 days ago Escape.php 9 months ago Glob.php 2 years ago Hooks.php 3 months ago Math.php 9 months ago PluginInfo.php 6 months ago Sanitize.php 3 months ago ServerVars.php 2 years ago SlashMode.php 5 years ago Strings.php 8 months ago Times.php 6 months ago Urls.php 1 month ago Version.php 1 year ago WpDefaultDirectories.php 2 years ago
Env.php
42 lines
1 <?php
2
3 namespace WPStaging\Framework\Utils;
4
5 /**
6 * Reads environment variables without assuming getenv() is callable.
7 *
8 * getenv() needs no extension, but a host can still drop it through the
9 * disable_functions ini directive. PHP >= 8.0 deletes a disabled function from
10 * the function table, so calling it directly raises "Call to undefined function"
11 * and takes the whole request down; PHP 7 leaves a stub that warns and returns
12 * null. function_exists() reports false in both cases, which is the guard used
13 * here, with $_SERVER and $_ENV as the fallback source.
14 */
15 class Env
16 {
17 /**
18 * @param string $name
19 * @return string|false The value, or false when the variable is not set,
20 * matching getenv()'s own contract.
21 */
22 public static function get(string $name)
23 {
24 // Read the live process environment first: it is the only source that
25 // reflects a putenv() call made during the current request.
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