I want to make a link to go to a url that is dynamically made, but I don't know how to do this with my code. Here is my Router class `
class Router
{
public $routes = [
'GET' => [],
'POST' => []
];
public static function load($file)
{
$router = new static;
require $file;
return $router;
}
public function get($uri, $controller)
{
$this->routes['GET'][$uri] = $controller;
}
public function post($uri, $controller)
{
$this->routes['POST'][$uri] = $controller;
}
public function direct($uri, $requestType)
{
if (array_key_exists($uri, $this->routes[$requestType])) {
return $this->routes[$requestType][$uri];
}
throw new Exception('No route defined for this URI.');
}
}
and here is my routes page
<?php
$router->get('', 'controllers/index.php');
$router->get('message', 'controllers/message.php');
$router->get('loginForm', 'controllers/loginForm.php');
$router->get('register', 'controllers/register.php');
on my page with my html I put an link with a dynamic link href='displayPost<?php echo $image->id; ?>
but I'm not sure how to add that $image->id; part into my router list and class to make dynamic url's.