urlToShortCode($_POST["url"]); $http = isset($_SERVER['HTTPS'])?'https':'http'; // printf('
Short URL: %2$s
',$http.'://'.$_SERVER['HTTP_HOST'], SHORTURL_PREFIX . $code); $arr = array( 'status' => 1, 'url' => $http.'://'.$_SERVER['HTTP_HOST']."/".$code, ); echo json_encode($arr); exit; } catch (Exception $e) { // log exception and then redirect to error page. // header("Location: index.php"); $arr = array( 'status' => 0, 'msg' => "地址有误", ); echo json_encode($arr); exit; }