當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


PHP ReflectionExtension getFunctions()用法及代碼示例


ReflectionExtension::getFunctions()函數是PHP中的內置函數,用於從指定的擴展名返回擴展名函數。

用法:

array ReflectionExtension::getFunctions( void )

參數:該函數不接受任何參數。


返回值:此函數從指定的擴展名返回擴展名函數。

以下示例程序旨在說明PHP中的ReflectionExtension::getFunctions()函數:

程序_1:

<?php 
  
// Defining an extension 
$A = 'DOM'; 
  
// Using ReflectionExtension() over the  
// specified extension 
$extension = new ReflectionExtension($A); 
  
// Calling the getFunctions() function 
$B = $extension->getFunctions(); 
  
// Getting extension functions from 
// the specified extension. 
var_dump($B); 
?>
輸出:
array(1) {
  ["dom_import_simplexml"]=>
  object(ReflectionFunction)#2 (1) {
    ["name"]=>
    string(20) "dom_import_simplexml"
  }
}

程序_2:

<?php 
  
// Using ReflectionExtension() over  
// a extension xml 
$extension = new ReflectionExtension('xml'); 
  
// Calling the getFunctions() function and 
// Getting extension functions from the 
// specified extension. 
var_dump($extension->getFunctions()); 
?>

輸出:

array(24) {
  ["xml_parser_create"]=>
  object(ReflectionFunction)#2 (1) {
    ["name"]=>
    string(17) "xml_parser_create"
  }
  ["xml_parser_create_ns"]=>
  object(ReflectionFunction)#3 (1) {
    ["name"]=>
    string(20) "xml_parser_create_ns"
  }
  ["xml_set_object"]=>
  object(ReflectionFunction)#4 (1) {
    ["name"]=>
    string(14) "xml_set_object"
  }
  ["xml_set_element_handler"]=>
  object(ReflectionFunction)#5 (1) {
    ["name"]=>
    string(23) "xml_set_element_handler"
  }
  ["xml_set_character_data_handler"]=>
  object(ReflectionFunction)#6 (1) {
    ["name"]=>
    string(30) "xml_set_character_data_handler"
  }
  ["xml_set_processing_instruction_handler"]=>
  object(ReflectionFunction)#7 (1) {
    ["name"]=>
    string(38) "xml_set_processing_instruction_handler"
  }
  ["xml_set_default_handler"]=>
  object(ReflectionFunction)#8 (1) {
    ["name"]=>
    string(23) "xml_set_default_handler"
  }
  ["xml_set_unparsed_entity_decl_handler"]=>
  object(ReflectionFunction)#9 (1) {
    ["name"]=>
    string(36) "xml_set_unparsed_entity_decl_handler"
  }
  ["xml_set_notation_decl_handler"]=>
  object(ReflectionFunction)#10 (1) {
    ["name"]=>
    string(29) "xml_set_notation_decl_handler"
  }
  ["xml_set_external_entity_ref_handler"]=>
  object(ReflectionFunction)#11 (1) {
    ["name"]=>
    string(35) "xml_set_external_entity_ref_handler"
  }
  ["xml_set_start_namespace_decl_handler"]=>
  object(ReflectionFunction)#12 (1) {
    ["name"]=>
    string(36) "xml_set_start_namespace_decl_handler"
  }
  ["xml_set_end_namespace_decl_handler"]=>
  object(ReflectionFunction)#13 (1) {
    ["name"]=>
    string(34) "xml_set_end_namespace_decl_handler"
  }
  ["xml_parse"]=>
  object(ReflectionFunction)#14 (1) {
    ["name"]=>
    string(9) "xml_parse"
  }
  ["xml_parse_into_struct"]=>
  object(ReflectionFunction)#15 (1) {
    ["name"]=>
    string(21) "xml_parse_into_struct"
  }
  ["xml_get_error_code"]=>
  object(ReflectionFunction)#16 (1) {
    ["name"]=>
    string(18) "xml_get_error_code"
  }
  ["xml_error_string"]=>
  object(ReflectionFunction)#17 (1) {
    ["name"]=>
    string(16) "xml_error_string"
  }
  ["xml_get_current_line_number"]=>
  object(ReflectionFunction)#18 (1) {
    ["name"]=>
    string(27) "xml_get_current_line_number"
  }
  ["xml_get_current_column_number"]=>
  object(ReflectionFunction)#19 (1) {
    ["name"]=>
    string(29) "xml_get_current_column_number"
  }
  ["xml_get_current_byte_index"]=>
  object(ReflectionFunction)#20 (1) {
    ["name"]=>
    string(26) "xml_get_current_byte_index"
  }
  ["xml_parser_free"]=>
  object(ReflectionFunction)#21 (1) {
    ["name"]=>
    string(15) "xml_parser_free"
  }
  ["xml_parser_set_option"]=>
  object(ReflectionFunction)#22 (1) {
    ["name"]=>
    string(21) "xml_parser_set_option"
  }
  ["xml_parser_get_option"]=>
  object(ReflectionFunction)#23 (1) {
    ["name"]=>
    string(21) "xml_parser_get_option"
  }
  ["utf8_encode"]=>
  object(ReflectionFunction)#24 (1) {
    ["name"]=>
    string(11) "utf8_encode"
  }
  ["utf8_decode"]=>
  object(ReflectionFunction)#25 (1) {
    ["name"]=>
    string(11) "utf8_decode"
  }
}

參考: https://www.php.net/manual/en/reflectionextension.getfunctions.php



相關用法


注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 PHP | ReflectionExtension getFunctions() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。