Home > Mobile >  Multiple retry PHP
Multiple retry PHP

Time:06-11

Is it possible to create a multiple verification about one variable? Like this:

<?php
$name = null;

if(isset($name)){

 $name = null;
 //Ah the name is again null, let's retry 
 if(isset($name)){
  $name = "Arthur";
  //Great! The name is arthur !
 }

}
?>

CodePudding user response:

Not sure the application you will give to the script, but this should do. Remember PHP will run the script first, then return the page. You cannot have an infinite loop running like JavaScript.

<?php

$name = null;

while (false === isset($name)) {

   // Your code in here

}
  •  Tags:  
  • php
  • Related