PHP输出当前进程所有变量常量等的方法介绍

WBOY
Libérer: 2016-07-25 09:00:54
original
899 Les gens l'ont consulté
  1. echo '
    ';     
    Copier après la connexion
  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 '
    ';      
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
  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 '
    ';      
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
  2. print_r(get_loaded_extensions());
  3. ?>
复制代码

4. get_extension_funcs (PHP 4, PHP 5) — 获取指定模块的可用函数 array get_extension_funcs ( string $module_name ) 该函数返回指定模块所有可用的函数。传入的参数(模块名称)必须是小写

  1. echo '
    ';      
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
  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 '
    ';      
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
  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 '
    ';      
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion
  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. ?>
复制代码


source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!