PHP code example of bramus / reflection

1. Go to this page and download the library: Download bramus/reflection library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bramus / reflection example snippets


	class Weekday
	{
		/**
		 * Monday
		 */
		const MONDAY = 1;

		/**
		 * Tuesday
		 */
		const TUESDAY = …
	}

	$reflected = new \ReflectionClass(Weekday::class);
	$constant = $reflected->getConstant('MONDAY');

	var_dump($constant);
	// int(1)
	

	class Weekday
	{
		/**
		 * Monday
		 */
		const MONDAY = 1;

		/**
		 * Tuesday
		 */
		const TUESDAY = …
	}

	$reflected = new \Bramus\Reflection\ReflectionClass(Weekday::class);
	$constants = $reflected->getConstant('MONDAY');

	var_dump($constant);
	// object(Bramus\Reflection\ReflectionClassConstant)#40 (2) {
	//   ["name"]=>
	//   string(6) "MONDAY"
	//   ["class"]=>
	//   string(7) "Weekday"
	//   ["docComment":"Bramus\Reflection\ReflectionClassConstant":private]=>
	//   object(phpDocumentor\Reflection\DocBlock)#86 (7) {
	//     …
	//   }
	// }