3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?php session_start(); require_once '../dbconfig.php'; if (isset($_POST)) { $title = trim($_POST['title']); $post_link = str_replace(" ", "_", strtolower(trim($_POST['title']))) != "" ? str_replace(" ", "_", strtolower(trim($_POST['title']))) : date_timestamp_get(date_create()); $img = $_POST['img']; $text = trim($_POST['text']); $chords = trim($_POST['chords']); $SC = trim($_POST["linkSC"]); $poster = $_SESSION["user_name"]; $dt = date('Y-m-d H:i:s'); $links = json_decode($_POST["links"], true); /* array of inputs */ try { $stmt = $db_con->prepare("INSERT INTO PJW_posts(title, post_link, img ,text, sc_link, chords, poster, datetime) VALUES(:title, :post_link, :img, :text, :sc, :chords, :poster, NOW())"); $stmt->bindParam(":title", $title); $stmt->bindParam(":post_link", $post_link); $stmt->bindParam(":img", $img); $stmt->bindParam(":text", $text); $stmt->bindParam(":sc", $SC); $stmt->bindParam(":chords", $chords); $stmt->bindParam(":poster", $poster); if ($stmt->execute()) { $_SESSION["post_id"] = $db_con->lastInsertId(); $last = $db_con->prepare("SELECT * FROM `PJW_posts` WHERE id=?"); $last->bindParam(1, $_SESSION["post_id"], PDO::PARAM_INT); $last->execute(); $post_link_1 = $last->fetch(PDO::FETCH_ASSOC); session_write_close(); /* insert helpful links */ /* ======================================== */ $hlinks = $db_con->prepare("INSERT INTO PJW_helpful_links SET parent=?, link=?, title=?, type=?, description=?, poster=?, datetime1=NOW()"); foreach ($links as $val) { $hlinks->execute(array($_SESSION["post_id"], $val["link"], $val["title"], $val["type"], $val["desc"], $_SESSION["user_name"])); } /* =========================================*/ echo json_encode(["status" => 200, "id" => $_SESSION["post_id"], "link" => $post_link_1["post_link"]]); exit; } else { echo json_encode(["status" => 422, "error" => "Database error."]); } } catch (PDOException $e) { echo json_encode(["status" => $e->getCode(), "error" => $e->getMessage()]); } }
Output for 7.1.0 - 7.1.16, 7.2.0 - 7.2.4
Parse error: syntax error, unexpected '<', expecting end of file in /in/lf1Oj on line 3
Process exited with code 255.

preferences:
160.07 ms | 1399 KiB | 29 Q