Witam. Mam problem z pewną funkcją która wywala mi błędy:
Notice: Undefined variable: b1 in ..\game.php on line 63
Notice: Undefined variable: b2 in ..\game.php on line 63
Notice: Undefined variable: b3 in ..\game.php on line 63
Notice: Undefined variable: b4 in ..\game.php on line 63
Notice: Undefined variable: b5 in ..\game.php on line 63
kod:
$a1 = rand(1, 8);
$a2 = rand(1, 8);
$a3 = rand(1, 8);
$a4 = rand(1, 8);
$a5 = rand(1, 8);
$b1 = rand(1, 8);
$b2 = rand(1, 8);
$b3 = rand(1, 8);
$b4 = rand(1, 8);
$b5 = rand(1, 8);
$c1 = rand(1, 8);
$c2 = rand(1, 8);
$c3 = rand(1, 8);
$c4 = rand(1, 8);
$c5 = rand(1, 8);
function jeden(){
// b1 b2 b3 b4 b5
if($b1==$b2 && $b2==$b3 && $b3==$b4 && $b4==$b5){ //linia 63
// 5
}
if(($b1==$b2 && $b2==$b3 && $b3==$b4) || ($b2==$b3 && $b3==$b4 && $b4==$b5)){
// 4
}
if(($b1==b2 && $b2==$b3) || ($b2==b3 && $b3==$b4) || ($b3==$b4 && $b4==$b5)){
//3
}
}
funkcja jest wywoływana niżej niż przypisanie wartości zmiennym. Dla celów testowych dodałem
$a1=0;
$a2=0;
$a3=0;
$a4=0;
$a5=0;
$b1=0;
$b2=0;
$b3=0;
$b4=0;
$b5=0;
$c1=0;
$c2=0;
$c3=0;
$c4=0;
$c5=0;
Program również w tym wypadku podaje błędy.