Matthew Hodge
Full Stack Developer

Lets say you have the following class, how do you output the contents of car variable?

class Car{
    public $make;

    public function __construct($make = null){
        $this->make = $make;
    }
}
$car = new Car('VW');

In order to debug the variable and output it to the screen you can use the following:

print_r($car)

You could also store the output into a variable which could be written later rather than output the contents to screen for example you would write it to a file:

$results = print_r($car, true); // $results now contains output from print_r