略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ReflectionClass::getModifiers

2024-04-24

ReflectionClass::getModifiers

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getModifiers获取类的修饰符

说明

public ReflectionClass::getModifiers(): int

返回这个类访问修饰符的位字段。

参数

此函数没有参数。

返回值

返回 修饰符常量 的位掩码。

参见

add a noteadd a note

User Contributed Notes 1 note

up
-8
Nicola Pietroluongo
7 years ago
It's the amount of memory allocation in bit.
By default many systems allocate 1048576 bit (1 Megabit).

/* Example 1 */

class Test {}
$classTest = new Test();
$reflectionClass = new \ReflectionClass('Test');
$classModifiers = $reflectionClass->getModifiers();
var_export($classModifiers);

//output
1048576

/* Example 2 */

class Test {}
//the constructor is missing
$reflectionClass = new \ReflectionClass('Test');
$classModifiers = $reflectionClass->getModifiers();
var_export($classModifiers);

//output
0

官方地址:https://www.php.net/manual/en/reflectionclass.getmodifiers.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3