I saw a publication in Stack Overflow about what I'm asking, but it did not meet what I'm looking for.
Reason for doubt is because I am doing a PHP course, but I do not know the problem is the version that was used, considering that the course is 2016. The code I learned is the same as the teacher does, but does not find the file, gives the 404 error.
<?php
include('configuracao.php');
include('usuarios.php');
include('produtos.php');
function getPagina()
{
$url = $_SERVER['REQUEST_URI'];
$url = explode("?", $url);
$metodo = $_SERVER['REQUEST_METHOD'];
// var_dump( $url ); exit;
if( $metodo == "GET" )
{
switch( $url )
{
case "/":
$produtos = getProdutos();
include( "Paginas/home.php" );
break;
case "/home":
$produtos = getProdutos();
include( "Paginas/home.php" );
break;
case "/sobre":
include( "Paginas/sobre.php" );
break;
case "/contato":
include( "Paginas/contato.php" );
break;
default:
$produtos = getProdutos();
include( "Paginas/home.php" );
break;
}
}
}
ThepurposeisthatwhentheusertypesintheURL,aftersite_address/"home" goes to their respective page, they enter "about" or "contact", and if the user types anything different, default would be redirected to the home page.
What could you do to find the files? I've tried using "./directory", I used single quotes, double quotation marks, etc.