ReflectionClass::hasProperty

(PHP 5 >= 5.1.2, PHP 7)

ReflectionClass::hasProperty锟斤拷锟斤拷锟斤拷锟斤拷欠锟斤拷讯锟斤拷锟�

说锟斤拷

public ReflectionClass::hasProperty ( string $name ) : bool

锟斤拷锟街革拷锟斤拷锟斤拷锟斤拷锟斤拷欠锟斤拷讯锟斤拷濉�

锟斤拷锟斤拷

name

锟斤拷锟斤拷锟斤拷锟斤拷锟皆碉拷锟斤拷锟狡★拷

锟斤拷锟斤拷值

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟皆凤拷锟斤拷 TRUE锟斤拷锟斤拷锟津返伙拷 FALSE锟斤拷

锟斤拷锟斤拷

Example #1 ReflectionClass::hasProperty() 锟斤拷锟斤拷

<?php
class Foo {
    public    
$p1;
    protected 
$p2;
    private   
$p3;

}

$obj = new ReflectionObject(new Foo());

var_dump($obj->hasProperty("p1"));
var_dump($obj->hasProperty("p2"));
var_dump($obj->hasProperty("p3"));
var_dump($obj->hasProperty("p4"));
?>

锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�

bool(true)
bool(true)
bool(true)
bool(false)

锟轿硷拷