Skip to content

Commit

Permalink
Check whether $obj is array or object
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmpage committed Feb 4, 2016
1 parent 7958e86 commit df17be6
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion api_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,27 @@
//--------------------------------------------------------------------------------------------------
function api_output($obj, $callback)
{
switch ($obj->status)
$status = 404;

// $obj may be array (e.g., for citeproc)
if (is_array($obj))
{
if (isset($obj['status']))
{
$status = $obj['status'];
}
}

// $obj may be object
if (is_object($obj))
{
if (isset($obj->status))
{
$status = $obj->status;
}
}

switch ($status)
{
case 303:
header('HTTP/1.1 404 See Other');
Expand Down

0 comments on commit df17be6

Please sign in to comment.