3v4l.org

run code in 300+ PHP versions simultaneously
/* inside index.php */ <div class="row"> <?php include_once 'show_posts.php'; ?> </div> /* show_posts.php */ <?php //session_start(); require_once 'dbconfig.php'; try { $stmt = $db_con->prepare("SELECT * FROM `PJW_posts`"); if ($stmt->execute()) { while ($results = $stmt->fetch(PDO::FETCH_ASSOC)) { include 'posts.phtml'; } } } catch (PDOException $e) { echo $e->getMessage(); } /* posts.phtml */ <div class="col-md-4"> <div class="card mb-4 box-shadow"> <img class="card-img-top" src="<?= htmlentities($results["img"], ENT_QUOTES) ?>"> <div class="card-body"> <h3><?= htmlentities($results["title"], ENT_QUOTES) ?></h3> <p class="card-text"><?= htmlentities(substr($results["text"], 0, 200), ENT_QUOTES) ?>...</p> <div class="d-flex justify-content-between align-items-center"> <div class="btn-group"> <button type="button" class="btn btn-sm btn-outline-secondary" onclick="window.location.href = '<?= htmlentities($results["id"], ENT_QUOTES) ?>/<?= htmlentities($results["post_link"], ENT_QUOTES) ?>'">View</button> /* user button */ <?php session_start(); if ($_SESSION["user_admin"]) { $edit_link = htmlentities($results["id"]) . "/" . htmlentities($results["post_link"]); echo '<button type="button" class="btn btn-sm btn-outline-danger" onclick="window.location.href="' . $edit_link . '">Update</button>'; } ?> /* admin button */ </div> <small class="text-muted">Added: <?= htmlentities($results["datetime"], ENT_QUOTES) ?></small> </div> </div> </div> </div>
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/8sHtW on line 29
Process exited with code 255.

preferences:
171.69 ms | 1395 KiB | 29 Q