PHP輸出當(dāng)前進(jìn)程所有變量/常量/模塊/函數(shù)/類的示例
更新時(shí)間:2013年11月07日 15:02:59 作者:
PHP輸出當(dāng)前進(jìn)程所有變量、常量、模塊、函數(shù)、類的示例
1. get_defined_vars (PHP 4 >= 4.0.4, PHP 5) — 獲取由所有已定義變量所組成的數(shù)組
array get_defined_vars ( void )
此函數(shù)返回一個(gè)包含所有已定義變量列表的多維數(shù)組,這些變量包括環(huán)境變量、服務(wù)器變量和用戶定義的變量。
<?php
echo '<pre>';
$b = array(1,1,2,3,5,8);
$arr = get_defined_vars();
// 打印 $b
print_r($arr["b"]);
// 打印所有服務(wù)器變量
print_r($arr["_SERVER"]);
// 打印變量數(shù)組的所有可用鍵值
print_r(array_keys(get_defined_vars()));
?>
2. get_defined_functions (PHP 4 >= 4.0.4, PHP 5) — 獲取所有已經(jīng)定義的函數(shù)
array get_defined_functions ( void ) //void 表示為空,不需要任何參數(shù)
<?php
echo '<pre>';
function foo()
{
echo "This is my function foo";
}
$arr = get_defined_functions();
print_r($arr);
?>
3. get_loaded_extensions (PHP 4, PHP 5) — 獲取所有可用的模塊
<?php
echo '<pre>';
print_r(get_loaded_extensions());
?>
4. get_extension_funcs (PHP 4, PHP 5) — 獲取指定模塊的可用函數(shù)
array get_extension_funcs ( string $module_name ) 該函數(shù)返回指定模塊所有可用的函數(shù)。傳入的參數(shù)(模塊名稱)必須是小寫
<?php
echo '<pre>';
print_r(get_extension_funcs("gd"));
print_r(get_extension_funcs("xml"));
?>
5. get_defined_constants (PHP 4 >= 4.1.0, PHP 5) — 獲取關(guān)聯(lián)數(shù)組的名字所有的常量和他們的價(jià)值
array get_defined_constants ([ bool $categorize = false ] )
<?php
echo '<pre>';
define("MY_CONSTANT", 1);
print_r(get_defined_constants(true));
?>
6. get_declared_classes (PHP 4, PHP 5) — 獲取由已定義類的名字所組成的數(shù)組
array get_declared_classes ( void )
<?php
echo '<pre>';
//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());
?>
array get_defined_vars ( void )
此函數(shù)返回一個(gè)包含所有已定義變量列表的多維數(shù)組,這些變量包括環(huán)境變量、服務(wù)器變量和用戶定義的變量。
復(fù)制代碼 代碼如下:
<?php
echo '<pre>';
$b = array(1,1,2,3,5,8);
$arr = get_defined_vars();
// 打印 $b
print_r($arr["b"]);
// 打印所有服務(wù)器變量
print_r($arr["_SERVER"]);
// 打印變量數(shù)組的所有可用鍵值
print_r(array_keys(get_defined_vars()));
?>
2. get_defined_functions (PHP 4 >= 4.0.4, PHP 5) — 獲取所有已經(jīng)定義的函數(shù)
array get_defined_functions ( void ) //void 表示為空,不需要任何參數(shù)
<?php
echo '<pre>';
function foo()
{
echo "This is my function foo";
}
$arr = get_defined_functions();
print_r($arr);
?>
3. get_loaded_extensions (PHP 4, PHP 5) — 獲取所有可用的模塊
復(fù)制代碼 代碼如下:
<?php
echo '<pre>';
print_r(get_loaded_extensions());
?>
4. get_extension_funcs (PHP 4, PHP 5) — 獲取指定模塊的可用函數(shù)
array get_extension_funcs ( string $module_name ) 該函數(shù)返回指定模塊所有可用的函數(shù)。傳入的參數(shù)(模塊名稱)必須是小寫
復(fù)制代碼 代碼如下:
<?php
echo '<pre>';
print_r(get_extension_funcs("gd"));
print_r(get_extension_funcs("xml"));
?>
5. get_defined_constants (PHP 4 >= 4.1.0, PHP 5) — 獲取關(guān)聯(lián)數(shù)組的名字所有的常量和他們的價(jià)值
array get_defined_constants ([ bool $categorize = false ] )
復(fù)制代碼 代碼如下:
<?php
echo '<pre>';
define("MY_CONSTANT", 1);
print_r(get_defined_constants(true));
?>
6. get_declared_classes (PHP 4, PHP 5) — 獲取由已定義類的名字所組成的數(shù)組
array get_declared_classes ( void )
復(fù)制代碼 代碼如下:
<?php
echo '<pre>';
//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());
?>
相關(guān)文章
YII2.0之Activeform表單組件用法實(shí)例
這篇文章主要介紹了YII2.0之Activeform表單組件用法,結(jié)合實(shí)例形式Activeform表單組件的具體類型及相關(guān)使用技巧,需要的朋友可以參考下2016-01-01PHP實(shí)現(xiàn)微信小程序人臉識(shí)別刷臉登錄功能
本文通過(guò)實(shí)例代碼給大家講解了基于PHP實(shí)現(xiàn)微信小程序人臉識(shí)別刷臉登錄功能,感興趣的朋友跟隨腳本之家小編一起學(xué)習(xí)吧2018-05-05php后臺(tái)多用戶權(quán)限組思路與實(shí)現(xiàn)程序代碼分享
很多時(shí)候我們?cè)匍_(kāi)發(fā)過(guò)程中需要考慮到多用戶權(quán)限問(wèn)題,這篇文章大家可以參考下2012-02-02laravel框架模型、視圖與控制器簡(jiǎn)單操作示例
這篇文章主要介紹了laravel框架模型、視圖與控制器簡(jiǎn)單操作,結(jié)合簡(jiǎn)單示例形式分析了laravel框架模型、視圖與控制器的基本操作技巧,需要的朋友可以參考下2019-10-10thinkPHP5(TP5)實(shí)現(xiàn)改寫跳轉(zhuǎn)提示頁(yè)面的方法
這篇文章主要介紹了thinkPHP5(TP5)實(shí)現(xiàn)改寫跳轉(zhuǎn)提示頁(yè)面的方法,結(jié)合實(shí)例形式分析了thinkPHP5跳轉(zhuǎn)提示頁(yè)面的修改步驟與相關(guān)操作注意事項(xiàng),需要的朋友可以參考下2017-10-10destoon實(shí)現(xiàn)會(huì)員商鋪中指定會(huì)員或會(huì)員組投放廣告的方法
這篇文章主要介紹了destoon實(shí)現(xiàn)會(huì)員商鋪中指定會(huì)員或會(huì)員組投放廣告的方法,很實(shí)用的技巧,需要的朋友可以參考下2014-08-08