get_defined_vars()函數傳回由所有已定義變數所組成的陣列。
版本需求:PHP 4 >= 4.0.4, PHP 5, PHP 7
array get_defined_vars ( void )
參數說明:
void。
傳回一個包含所有已定義變數清單的多維數組,這些變數包括環境變數、伺服器變數和使用者定義的變數。
執行結果如下圖所示:
Array( [0] => 1 [1] => 1 [2] => 2 [3] => 3 [4] => 5 [5] => 8)Array( [0] => /tmp/543750210 /main.php)Array( [PATH] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin [HOSTNAME] => glot-runner [PHPIZE_DEPS] => autoconf dpkg-dev file g++ gcc libc -dev make pkg-config re2c [PHP_INI_DIR] => /usr/local/etc/php [PHP_CFLAGS] => -fstack-protector-strong -fpic -fpie -O2 [PHP_CPPFLAGS] => -fstack-protector-strong -fpic -fpie -O2 [PHP_LDFLAGS] => -Wl,-O1 -Wl,--hash -style=both -pie [GPG_KEYS] => 1729F83938DA44E27BA0F4D3DBDB397470D12172 B1B44D8F021E4E2D6021E995DC9FF8D3EE5AF27F [PHP_VERSION] => 7.2.1 https://secure.php.net/get/php-7.2.1.tar.xz/from/this/mirror [PHP_ASC_URL] => https://secure.php.net/get/php-7.2.1. tar.xz.asc/from/this/mirror [PHP_SHA256] => 6c6cf82fda6660ed963821eb0525214bb3547e8e29f447b9c15b2d8e6efd8822 [PHP_MD5] => [HOME] => /home/glot [PHP_SELF] => 745]> /tmp/543750210/main.php [SCRIPT_FILENAME] => /tmp/543750210/main.php [PATH_TRANSLATED] => /tmp/543750210/main.php [DOCUMENT_ROOT] =]REST [REQUEST_TIME] => 1524198667 [argv] => Array ( [0] => /tmp/543750210/main.php ) [argc] => 1)Array( [0] => _GET [1] => _POST [2 ] => _COOKIE [3] => _FILES [4] => argv [5] => argc [6] => _SERVER [7] => b [8] => arr)