$ajaxErrors, 'php'=>$errors)); exit(0); } foreach (array('{}', '{"command":"1"}', '{"connkey":"123"}') as $request) { $out = json_decode(shell_exec(escapeshellarg(PHP_BINARY).' '.escapeshellarg(__FILE__).' '.escapeshellarg($request)), true); check("$request reports the missing parameters", $out && count($out['ajax']) == 1 && strpos($out['ajax'][0], 'No connkey or no command') === 0); check("$request raises no PHP warning", $out && count($out['php']) == 0); if ($out && $out['php']) echo ' '.implode("\n ", $out['php'])."\n"; } exit($failures ? 1 : 0);