How can class variables impact the output of json_encode in PHP?

When using `json_encode` in PHP, class variables that are not public will not be included in the output. To ensure that all class variables are included in the JSON output, you can either make the variables public or implement a `jsonSerialize` method in the class that returns an array of all the class variables.

class MyClass implements JsonSerializable {
    private $privateVar = 'private';
    public $publicVar = 'public';

    public function jsonSerialize() {
        return get_object_vars($this);
    }
}

$obj = new MyClass();
echo json_encode($obj);