PHP code example of divinity76 / phprouter
1. Go to this page and download the library: Download divinity76/phprouter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
divinity76 / phprouter example snippets
er = new \Divinity76\Phprouter\Phprouter();
$router->get('/test', function() {
echo 'test GET page';
});
$router->post("/test",function(){
echo "test POST page";
});
$router->match("PATCH","/user/(\d+)/([^\\/])?",function(string $user_id, string $user_name_supplied){
echo "you accessed user #".htmlentities($user_id).
", you think his name is ".htmlentities($user_name)."...");
});
$router->set404(function(){
echo "404 not found: ".htmlentities($_SERVER['REQUEST_URI']);
});
$router->run();