<?php require "blog.php"; use Blog\DB; // Fetch all posts $post = DB\get_by_id((int) $_GET["id"], $conn); if ($post) { $post = $post[0]; view("single", array("post" => $post)); } else { header("location:/sandbox/blog"); }
<?php require 'blog.php'; use Blog\DB; $post = DB\get_by_id((int) $_GET['id'], $conn); if ($post) { $post = $post[0]; view('single', array('post' => $post)); } else { header('Location: index.php'); } // $view_path = 'views/single.view.php'; // include 'views/layout.php';
<?php require 'blog.php'; use Blog\DB; $post = DB\get_by_id($_GET['id'], $conn); if (!$post) { header('location:/blog'); } $data = ['post' => $post]; view('single', $data);