Skip to content

Instantly share code, notes, and snippets.

@zircote
Created June 18, 2013 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zircote/5806676 to your computer and use it in GitHub Desktop.
Save zircote/5806676 to your computer and use it in GitHub Desktop.
ProTip: Test the key exists before accessing the value in the switch.
<?php
switch (isset($headers['content-type']) && $headers['content-type']) {
case 'application/xml':
$format = 'XML';
break;
case 'application/json':
default:
$format = 'JSON';
}
echo $format;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment