June 2017
Intermediate to advanced
536 pages
9h 49m
English
The __debugInfo() magic method gets triggered when the var_dump() function is called. By default, the var_dump() function shows all public, protected, and private properties of an object. However, if an object class implements the __debugInfo() magic method, we get to control the output of the var_dump() function. The method does not accept any parameters, and returns an array of key-values to be shown, as per the following synopsis:
array __debugInfo(void)
The following example demonstrates the __debugInfo() method implementation:
<?phpclass User{ public $name = 'John'; public $age = 34; private $salary = 4200.00; private $bonus = 680.00; protected $identifier = 'ABC'; protected $logins = 67; public function __debugInfo() ...Read now
Unlock full access