// Assume we have a page called 'user-edit.php' // We want to generate a link to edit a user with id=5 $id = 5; $link = Router::generateURL('user-edit', array('id' => $id)); echo "Edit User {$id}";
// Assume we have a page called 'category.php' // We want to generate a link to view a category with id=3 and name='books' $id = 3; $name = 'books'; $link = Router::generateURL('category', array('id' => $id, 'name' => $name)); echo "{$name}";In this example, we are generating a URL for a page called 'category.php', and passing two parameters: 'id' with a value of 3, and 'name' with a value of 'books'. The resulting URL will look something like this: 'http://example.com/category.php?id=3&name=books' Package library: The code examples above are just generic examples, and there is no specific package library mentioned. However, there are many PHP frameworks and libraries that include a routing system, such as Laravel, Symfony, Slim, and more.