route php code example
Example 1: php routing
<?php
$request = $_SERVER['REQUEST_URI'];
switch ($request) {
case '/' :
require __DIR__ . '/views/index.php';
break;
case '' :
require __DIR__ . '/views/index.php';
break;
case '/about' :
require __DIR__ . '/views/about.php';
break;
default:
http_response_code(404);
require __DIR__ . '/views/404.php';
break;
}
Example 2: laraval routing
Route::redirect('/here', '/there', 301);
Example 3: laravel route match
Route::match(['get', 'post'], '/', function () {
});
Route::any('/', function () {
});
Example 4: laravel route
Route::get('user/profile', [UserProfileController::class, 'show'])->name('profile');