To function or operation target class: Method of obtaining the name of a class, the class attribute name

class A{

​ public $a = 1;

​ protected $b = 2;

​ public function __construct()

​ {

​ echo 'fe'."\n";

​ }

​ public static function index(){

​ echo 'index'."\n";

​ }

​ protected function ddd(){

​ }

}

$a = new A;

$b = '';

// Check whether the class A is defined

echo class_exists('A')."\n";

// Gets an instance of the class $ a name

echo get_class($a)."\n";

// If it is not passed in the variable object type, a warning

echo get_class($b)."\n";

// returns public properties of the class array of

print_r( get_class_vars("A") );

// public method returns an array of subjects or classes consisting of

print_r( get_class_methods( $a ) );

Guess you like

Origin www.cnblogs.com/zxcv123/p/12094047.html