php - Loop until variable is isset then excute a code -


i try while loop missing need loop until variable isset execute code dis :

$counter=o; while(null!==($var)){   $counter ++; } if (isset($var)){ excute code ....  } 

you mean this?

$counter = 0; while (!isset($var)) {     $counter ++;     echo $counter, php_eol;     if ($counter == 10) {         $var = true;     } }  echo 'done', php_eol; 

i suggest don't use existance of variable control logic flow - using break command kill potentially infinite loop might better, example:

while (true) {     //     if ($somecondition) {         break;     } } 

Comments