PHP returning part of the code document
<p>I have a PHP page that does a couple of different things depending on what <code>action</code> is set to in the GET data. Depending, it is supposed to return some JSON, but instead of doing anything it is supposed to it returns the bottom half of the code document itself, starting in the middle of the line. Heres the snippit from where it starts:</p>

<pre><code>...
} elseif ($_GET['action'] == 'addtop') {
    if (!isset($_GET['pname']) || !isset($_GET['url']) || !isset($_GET['artist']) || !isset($_GET['album']) || !isset($_GET['file'])) {
        die('Error: Incomplete data!');
    }
    if (!file_exists($_GET['pname'].".txt")) {
        die('Error: No such playlist!');
    }
    $plist = json_decode(file_get_contents($_GET['pname'].".txt"), true);
    $fh = fopen($_GET['pname'].".txt", 'w') or die('Could not open playlist!');
    array_push($plist, array("artist" =&gt; $_GET['artist'], "album" =&gt; $_GET['album'], "file" =&gt; $_GET['file'], "url" =&gt; $_GET['url']));
    fwrite($fh,json_encode($plist));
} elseif ($_GET['action'] == 'delfromp') {
...
</code></pre>

<p>And here is what I get when I go to the page:</p>

<blockquote>
  <p>$_GET['artist'], "album" =>
  $_GET['album'], "file" =>
  $_GET['file'], "url" =>
  $_GET['url']));
  fwrite($fh,json_encode($plist)); }
  elseif ($_GET['action'] == 'delfromp')
  { if (!isset($_GET['pname']) ||
  !isset($_GET['id'])) { die('Error:
  Incomplete data!'); } if
  (!file_exists($_GET['pname'].".txt"))
  { die('Error: No such playlist!'); }
  $plist =
  json_decode(file_get_contents($_GET['pname'].".txt"),
  true); $fh =
  fopen($_GET['pname'].".txt", 'w') or
  die('Could not open playlist!');
  unset($plist[$_GET['id']]); $plist =
  array_values($plist);
  fwrite($fh,json_encode($plist)); }
  elseif ($_GET['action'] == 'readp') {
  if
  (!file_exists($_GET['pname'].".txt"))
  { die('Error: No such playlist!'); }
  $plist =
  json_decode(file_get_contents($_GET['pname'].".txt"),
  true); $arr = array("entries" =>
  $plist); $json = json_encode($arr);
  echo $json; } elseif ($_GET['action']
  == 'getps') { $plists = array(); if ($handle = opendir('Playlists')) {
  while (false !== ($playlist =
  readdir($handle))) { if ($playlist !=
  "." &amp;&amp; $playlist != "..") {
  array_push($plists, substr($playlist,
  0, strripos($playlist, '.')-1)); } } }
  else { die('Error: Can\'T open
  playlists!'); } $arr =
  array("entries"=>$plists); $json =
  json_encode($arr); echo $json; } else
  { die('Error: No such action!'); } ?></p>
</blockquote>

<p>It starts in the middle of the <code>array_push(...</code> line.</p>

<p>I really can't think of what it is doing. Theres no <code>echo</code>s anywhere around it. Any ideas?</p>
