I have a form where the user will type a particular path, eg: / var / www ... I want to check if the user typed a / at the end example /var/www/.../, that is if the last character was a /, if it has not typed to make it include,
I have a form where the user will type a particular path, eg: / var / www ... I want to check if the user typed a / at the end example /var/www/.../, that is if the last character was a /, if it has not typed to make it include,
You can do this as follows:
$caminho = $_POST['caminho'];
// nisso ele pegará o último caracter do caminho e verificará se é uma barra,
// se não for ele adicionará
$barra = substr($caminho, -1);
if ($barra != '/'){
$caminho += '/';
}