PHP | ReflectionProperty getModifiers() Function
The ReflectionProperty::getModifiers() function is an inbuilt function in PHP which is used to return the numeric representation of the specified modifiers.
Syntax:
int ReflectionProperty::getModifiers ( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns the numeric representation of the specified modifiers.
Below programs illustrate the ReflectionProperty::getModifiers() function in PHP:
Program 1:
<?php
class Company {
public $SizeOfGeeksforGeeks = 13;
protected $SizeOfGFG = 3;
}
$A = new ReflectionProperty( 'Company' , 'SizeOfGeeksforGeeks' );
$B = new ReflectionProperty( 'Company' , 'SizeOfGFG' );
$C = $A ->getModifiers();
$D = $B ->getModifiers();
var_dump( $C );
var_dump( $D );
?>
|
Output:
int(256)
int(512)
Program 2:
<?php
class Department1
{
protected $SizeOfHR = 2;
}
class Department2
{
public $SizeOfCoding = 6;
}
class Department3
{
private $SizeOfMarketing = 9;
}
$A = new ReflectionProperty( 'Department1' , 'SizeOfHR' );
$B = new ReflectionProperty( 'Department2' , 'SizeOfCoding' );
$C = new ReflectionProperty( 'Department3' , 'SizeOfMarketing' );
$D = $A ->getModifiers();
$E = $B ->getModifiers();
$F = $C ->getModifiers();
var_dump( $D );
var_dump( $E );
var_dump( $F );
?>
|
Output:
int(512)
int(256)
int(1024)
Reference: https://www.php.net/manual/en/reflectionproperty.getmodifiers.php
Last Updated :
30 Dec, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...