PHP ReflectionClass hasProperty() Function
Last Updated :
22 Feb, 2021
The ReflectionClass hasProperty() function is an inbuilt function in PHP that is used to check the specified property is present or not.
Syntax:
bool ReflectionClass hasProperty( string $name )
Parameters: This function accepts a single parameter $name which holds the name of the property that is being checked.
Return Value: This function returns true if the specified property is present, otherwise returns false.
Below programs illustrate the ReflectionClass hasProperty() function in PHP:
Program 1:
php
<?php
$ReflectionClass = new ReflectionClass( 'ReflectionClass' );
$a = 'name' ;
$Property = $ReflectionClass ->hasProperty( $a );
var_dump( $Property );
?>
|
Program 2:
php
<?php
class Company {
Public Function GeeksforGeeks() {}
Private Function GFG() {}
}
$Class = new ReflectionClass( 'Company' );
$A = $Class ->hasProperty( $Class );
var_dump( $A );
?>
|
Reference: https://www.php.net/manual/en/reflectionclass.hasproperty.php
Share your thoughts in the comments
Please Login to comment...