1. get_defined_vars (PHP 4 >= 4.0.4, PHP 5) — 擷取由所有已定義變數所組成的數組
array get_defined_vars ( void )
此函數返回一個包含所有已定義變數列表的多維陣列,這些變數包括環境變數、伺服器變數和使用者定義的變數。
複製代碼 代碼如下:
echo '
';
$b = array(1,1,2,3,5,8);
$arr = get_defined_vars();
// 列印 $b
print_r($arr["b"]);
// 列印所有伺服器變數
print_r($arr["_SERVER"]);
// 列印變數數組的所有可用索引值
print_r(array_keys(get_defined_vars()));
?>
2. get_defined_functions (PHP 4 >= 4.0.4, PHP 5) — 擷取所有已經定義的函數
array get_defined_functions ( void ) //void 表示為空白,不需要任何參數
echo '';
function foo()
{
echo "This is my function foo";
}
$arr = get_defined_functions();
print_r($arr);
?>
3. get_loaded_extensions (PHP 4, PHP 5) — 擷取所有可用的模組
複製代碼 代碼如下:
echo '';
print_r(get_loaded_extensions());
?>
4. get_extension_funcs (PHP 4, PHP 5) — 擷取指定模組的可用函數
array get_extension_funcs ( string $module_name ) 該函數返回指定模組所有可用的函數。傳入的參數(模組名稱)必須是小寫
複製代碼 代碼如下:
echo '';
print_r(get_extension_funcs("gd"));
print_r(get_extension_funcs("xml"));
?>
5. get_defined_constants (PHP 4 >= 4.1.0, PHP 5) — 擷取關聯陣列的名字所有的常量和他們的價值
array get_defined_constants ([ bool $categorize = false ] )
複製代碼 代碼如下:
echo '';
define("MY_CONSTANT", 1);
print_r(get_defined_constants(true));
?>
6. get_declared_classes (PHP 4, PHP 5) — 擷取由已定義類的名字所組成的數組
array get_declared_classes ( void )
複製代碼 代碼如下:
echo '';
//define classone
class classone { }
//define classtwo
class classtwo { }
//This will show X classes (built-ins, extensions etc) with
//classone and classtwo as the last two elements
print_r(get_declared_classes());
//define classthree
class classthree { }
//...and four
class classfour { }
//Shows the same result as before with class three and four appended
print_r(get_declared_classes());
?>