To be honest I'm looking for the return "unnecessarily", but I'm curious, I'm just starting with php and searched but I could not find it.
I use the interpreter to execute a small php that I did and the idea would be to execute itself instead of using a loop (since we still "did not see that").
I put a simple code that would represent what I want to do:
numero.php
<?php
echo "Ingrese un número de 1 a 10: ";
$numero = trim(fgets(STDIN));
if($numero < 1 || $numero > 10) {
echo "Número incorrecto, ¿prueba otra vez? (S/N): ";
$respuesta = strtoupper(trim(fgets(STDIN)));
if($respuesta == "S") {
llamar numero.php
}
}
echo "\n";
?>
I tried using shell_exec (), it does not give an error, but it does not answer anything anymore.
Just in case, if it makes any difference, I'm using Linux.
Eduardo's suggestion:
<?php
include("./numero.php");
echo "Ingrese un número de 1 a 10: ";
$numero = trim(fgets(STDIN));
if($numero < 1 || $numero > 10) {
echo "Número incorrecto, ¿prueba otra vez? (S/N): ";
$respuesta = strtoupper(trim(fgets(STDIN)));
if($respuesta == "S") {
numero();
}
}
echo "\n";
?>
When you run it with php numero.php
it does nothing, having to finish the execution with CTRL + C
And using header("Location: numero.php");
as Eduardo suggested, I would not know how to execute numero.php
from if($respuesta == "S")