php輸出當前進程所有變數、常量、模組、函數、類

來源:互聯網
上載者:User
  1. echo '
    ';  
  2. $b = array(1,1,2,3,5,8);
  3. $arr = get_defined_vars();
  4. // 列印 $b
  5. print_r($arr["b"]);
  6. // 列印所有伺服器變數
  7. print_r($arr["_SERVER"]);
  8. // 列印變數數組的所有可用索引值
  9. print_r(array_keys(get_defined_vars()));
  10. ?>
複製代碼

2. get_defined_functions (PHP 4 >= 4.0.4, PHP 5) — 擷取所有已經定義的函數array get_defined_functions ( void ) //void 表示為空白,不需要任何參數

  1. echo '
    ';  
  2. function foo()
  3. {
  4. echo "This is my function foo";
  5. }
  6. $arr = get_defined_functions();
  7. print_r($arr);
  8. ?>
複製代碼

3. get_loaded_extensions (PHP 4, PHP 5) — 擷取所有可用的模組

  1. echo '
    '; 
  2. print_r(get_loaded_extensions());
  3. ?>
複製代碼

4. get_extension_funcs (PHP 4, PHP 5) — 擷取指定模組的可用函數array get_extension_funcs ( string $module_name ) 該函數返回指定模組所有可用的函數。傳入的參數(模組名稱)必須是小寫

  1. echo '
    ';  
  2. print_r(get_extension_funcs("gd"));
  3. print_r(get_extension_funcs("xml"));
  4. ?>
複製代碼

5. get_defined_constants (PHP 4 >= 4.1.0, PHP 5) — 擷取關聯陣列的名字所有的常量和他們的價值array get_defined_constants ([ bool $categorize = false ] )

  1. echo '
    ';  
  2. define("MY_CONSTANT", 1);
  3. print_r(get_defined_constants(true));
  4. ?>
複製代碼

6. get_declared_classes (PHP 4, PHP 5) — 擷取由已定義類的名字所組成的數組array get_declared_classes ( void )

  1. echo '
    ';  
  2. //define classone
  3. class classone { }
  4. //define classtwo
  5. class classtwo { }
  6. //This will show X classes (built-ins, extensions etc) with
  7. //classone and classtwo as the last two elements
  8. print_r(get_declared_classes());
  9. //define classthree
  10. class classthree { }
  11. //...and four
  12. class classfour { }
  13. //Shows the same result as before with class three and four appended
  14. print_r(get_declared_classes());
  15. ?>
複製代碼
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.