PHPTS:一键免费搭建 Nginx + PHP + MySQL 运行环境

ReflectionProperty::getType

(PHP 7 >= 7.4.0)

ReflectionProperty::getTypeGets a property's type

说明

public ReflectionProperty::getType ( void ) : ?ReflectionType

Gets the associated type of a property.

参数

此函数没有参数。

返回值

Returns a ReflectionType if the property has a type, and NULL otherwise.

范例

Example #1 ReflectionProperty::getType() example

<?php
class User
{
    public 
string $name;
}

$rp = new ReflectionProperty('User''name');
echo 
$rp->getType()->getName();
?>

以上例程会输出:

string

参见