Vesthelm Engine

2.1.1 User Guide

Output Class

The Output class provides functions to output specific data: JSON strings, HTML pages, error messages etc.

Calling the Output Class

$Output = $this->Output;

Output 404 Not Found Page

Shows 404 not found page:

$this->Output->msg('404');

Output 403 Forbidden Page

Shows 403 forbidden page:

$this->Output->msg('403');

Output Denied Page

Shows denied page:

$this->Output->deny();

Output JSON Data

Shows JSON string:

$data = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);

$this->Output->json($data); //output will be string ({"a":1,"b":2,"c":3,"d":4,"e":5})

The first argument is the data to encode. Second argument - bool, if true json encoded string will be outputted using echo() function.

Get JSON string:

$data = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);

$json_string = $this->Output->json($data, false); //$json_string will contain string ({"a":1,"b":2,"c":3,"d":4,"e":5})