Skip to content

Instantly share code, notes, and snippets.

@Zegnat Zegnat/Class.php
Created Apr 13, 2016

What would you like to do?
* Send JSON encoded data to the browser and end all further processing.
* @method endWithJson
* @param array $data A data array.
* @throws InvalidArgumentException
* @return void
private function endWithJson($data)
if (!is_array($data)) {
throw new \InvalidArgumentException('Method endWithJson requires a data array as argument.');
header('Content-type: application/json');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.