ReflectionClass::getStaticProperties()函数是PHP中的内置函数,用于返回静态属性数组。该函数当前未记录,但其参数列表可用。
用法:
ReflectionClass::getStaticProperties(void) : array
参数:该函数不接受任何参数。
返回值:此函数返回静态属性的数组。
以下示例程序旨在说明PHP中的ReflectionClass::getStaticProperties()函数:
示例1:
<?php 
   
// Defining a class named as Departments 
class Departments { 
    public $Dept1 = 'CSE'; 
    private $Dept2 = 'ECE'; 
    public static $Dept3 = 'EE'; 
} 
   
// Using ReflectionClass over the class Departments 
$ReflectionClass = new ReflectionClass('Departments'); 
   
// Calling getStaticProperties() function 
$A = $ReflectionClass->getStaticProperties(); 
   
// Getting an array of the static properties 
var_dump($A); 
?>输出:
array(1) {
  ["Dept3"]=>
  string(2) "EE"
}
示例2:
<?php 
  
// Defining a class named as Departments 
class GFG { 
    static $name = "GeeksforGeeks"; 
    private static $addr = "Noida"; 
    protected static $email = 'abc@geeksforgeeks.org'; 
} 
  
// Using ReflectionClass  
$ReflectionClass = new ReflectionClass('GFG'); 
  
// Calling getStaticProperties() function 
$Property = $ReflectionClass->getStaticProperties(); 
  
// Getting an array of the static properties 
// if present 
var_dump($Property); 
?>输出:
array(3) {
  ["name"]=>
  string(13) "GeeksforGeeks"
  ["addr"]=>
  string(5) "Noida"
  ["email"]=>
  string(21) "abc@geeksforgeeks.org"
}
参考: https://www.php.net/manual/en/reflectionclass.getstaticproperties.php
相关用法
- PHP ReflectionClass isIterateable()用法及代码示例
- PHP ReflectionClass isUserDefined()用法及代码示例
- PHP ReflectionClass getInterfaceNames()用法及代码示例
- PHP ReflectionClass getProperties()用法及代码示例
- PHP ReflectionClass getProperty()用法及代码示例
- PHP ReflectionClass getMethod()用法及代码示例
- PHP ReflectionClass isTrait()用法及代码示例
- PHP ReflectionClass getDefaultProperties()用法及代码示例
- PHP ReflectionClass isSubclassOf()用法及代码示例
- PHP ReflectionClass hasConstant()用法及代码示例
- PHP ReflectionClass inNamespace()用法及代码示例
- PHP ReflectionClass isAbstract()用法及代码示例
- PHP ReflectionClass isAnonymous()用法及代码示例
- PHP ReflectionClass getStartLine()用法及代码示例
- PHP ReflectionClass implementsInterface()用法及代码示例
注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 PHP | ReflectionClass getStaticProperties() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
