3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php<?php session_start(); error_reporting(0); //Fprint_r($_SESSION); $_SESSION['what'] ='gracz'; //print_r($_SESSION); if($_GET['set']){ if($_GET['set']=='kolko'){ $_SESSION['what']='gracz'; }else{ $_SESSION['what']='komputer'; } } if($_GET['act']=='postaw'){ if($_SESSION['pola'][$_GET['pole']]==''){ $_SESSION['pola'][$_GET['pole']]='gracz'; sprawdz($_SESSION['pola']); postaw($_SESSION['pola']); sprawdz($_SESSION['pola']); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Page title</title> <style type="text/css"> <!-- body{ background-color:#03a4ff; } td { background-color:#F2F238; width:150px; height:150px; text-align:center; } td.gracz{ background-color:#F8F8F8; } td.komputer{ background-color:#D5D5D5; } td.WIN{ background-color:#ff0e00; } span.gracz{ font-size:42px; } span.komputer{ font-size:42px; } ---> </style> <?php function ustaw($gdzie, $co){ if($_SESSION[$gdzie]==''){ $_SESSION[$gdzie]=$co; }else{ echo 'BRAK DOSTEPU'; } } function postaw($arrPola){ //print_r($_SESSION); if($_SESSION['koniec']==0){ if((($_SESSION["pola"]["0,0"]=='komputer' AND $_SESSION["pola"]["0,2"]=='komputer')OR($_SESSION["pola"]["1,1"]=='komputer' AND $_SESSION["pola"]["2,1"]=='komputer')) AND $_SESSION["pola"]["0,1"]==''){ $_SESSION["pola"]["0,1"] ='komputer'; echo '1'; }elseif($_SESSION["pola"]["1,0"]=='komputer' AND $_SESSION["pola"]["1,2"]=='komputer' AND $_SESSION["pola"]["1,1"]==''){ $_SESSION["pola"]["1,1"] ='komputer'; echo '2'; }elseif((($_SESSION["pola"]["2,0"]=='komputer' AND $_SESSION["pola"]["2,2"]=='komputer')OR($_SESSION["pola"]["0,1"]=='komputer' AND $_SESSION["pola"]["1,1"]=='komputer')) AND $_SESSION["pola"]["2,1"]==''){ $_SESSION["pola"]["2,1"] ='komputer'; echo '3'; }elseif($_SESSION["pola"]["1,0"]=='komputer' AND $_SESSION["pola"]["2,0"]=='komputer' AND $_SESSION["pola"]["0,0"]==''){ $_SESSION["pola"]["0,0"] ='komputer'; echo '4'; }elseif($_SESSION["pola"]["0,1"]=='komputer' AND $_SESSION["pola"]["2,1"]=='komputer' AND $_SESSION["pola"]["1,1"]==''){ $_SESSION["pola"]["1,1"] ='komputer'; echo '5'; }elseif((($_SESSION["pola"]["0,2"]=='komputer' AND $_SESSION["pola"]["2,2"]=='komputer')OR($_SESSION["pola"]["1,0"]=='komputer' AND $_SESSION["pola"]["1,1"]=='komputer')) AND $_SESSION["pola"]["1,2"]==''){ echo '6'; $_SESSION["pola"]["1,2"] ='komputer'; }elseif($_SESSION["pola"]["0,0"]=='komputer' AND $_SESSION["pola"]["2,2"]=='komputer' AND $_SESSION["pola"]["1,1"]==''){ $_SESSION["pola"]["1,1"] ='komputer'; }elseif($_SESSION["pola"]["2,0"]=='komputer' AND $_SESSION["pola"]["0,2"]=='komputer' AND $_SESSION["pola"]["1,1"]==''){ $_SESSION["pola"]["1,1"] ='komputer'; }elseif((($_SESSION["pola"]["0,0"]=='komputer' AND $_SESSION["pola"]["2,0"]=='komputer')OR($_SESSION["pola"]["1,1"]=='komputer' AND $_SESSION["pola"]["1,2"]=='komputer')) AND $_SESSION["pola"]["1,0"]==''){ $_SESSION["pola"]["1,0"] ='komputer'; }elseif($_SESSION["pola"]["2,0"]=='komputer' AND $_SESSION["pola"]["2,1"]=='komputer' AND $_SESSION["pola"]["2,2"]==''){ $_SESSION["pola"]["2,2"] ='komputer'; }elseif($_SESSION["pola"]["0,0"]=='komputer' AND $_SESSION["pola"]["1,0"]=='komputer' AND $_SESSION["pola"]["2,0"]==''){ $_SESSION["pola"]["2,0"] ='komputer'; }elseif($_SESSION["pola"]["0,0"]=='komputer' AND $_SESSION["pola"]["0,1"]=='komputer' AND $_SESSION["pola"]["0,2"]==''){ $_SESSION["pola"]["0,2"] ='komputer'; }elseif($_SESSION["pola"]["0,1"]=='komputer' AND $_SESSION["pola"]["0,2"]=='komputer' AND $_SESSION["pola"]["0,0"]==''){ $_SESSION["pola"]["0,0"] ='komputer'; }elseif($_SESSION["pola"]["2,1"]=='komputer' AND $_SESSION["pola"]["2,2"]=='komputer' AND $_SESSION["pola"]["2,0"]==''){ $_SESSION["pola"]["2,0"] ='komputer'; }elseif($_SESSION["pola"]["1,2"]=='komputer' AND $_SESSION["pola"]["2,2"]=='komputer' AND $_SESSION["pola"]["0,2"]==''){ $_SESSION["pola"]["0,2"] ='komputer'; }elseif($_SESSION["pola"]["0,2"]=='komputer' AND $_SESSION["pola"]["1,2"]=='komputer' AND $_SESSION["pola"]["2,2"]==''){ $_SESSION["pola"]["2,2"] ='komputer'; }elseif($_SESSION["pola"]["0,2"]=='komputer' AND $_SESSION["pola"]["1,1"]=='komputer' AND $_SESSION["pola"]["2,0"]==''){ $_SESSION["pola"]["2,0"] ='komputer'; }elseif($_SESSION["pola"]["2,0"]=='komputer' AND $_SESSION["pola"]["1,1"]=='komputer' AND $_SESSION["pola"]["0,2"]==''){ $_SESSION["pola"]["0,2"] ='komputer'; }elseif($_SESSION["pola"]["0,0"]=='komputer' AND $_SESSION["pola"]["1,1"]=='komputer' AND $_SESSION["pola"]["2,2"]==''){ $_SESSION["pola"]["2,2"] ='komputer'; }elseif($_SESSION["pola"]["1,1"]=='komputer' AND $_SESSION["pola"]["2,2"]=='komputer' AND $_SESSION["pola"]["0,0"]==''){ $_SESSION["pola"]["0,0"] ='komputer'; }elseif((($_SESSION["pola"]["0,0"]=='gracz' AND $_SESSION["pola"]["0,2"]=='gracz')OR($_SESSION["pola"]["1,1"]=='gracz' AND $_SESSION["pola"]["2,1"]=='gracz')) AND $_SESSION["pola"]["0,1"]==''){ $_SESSION["pola"]["0,1"] ='komputer'; echo '7'; }elseif($_SESSION["pola"]["1,0"]=='gracz' AND $_SESSION["pola"]["1,2"]=='gracz' AND $_SESSION["pola"]["1,1"]==''){ $_SESSION["pola"]["1,1"] ='komputer'; }elseif((($_SESSION["pola"]["2,0"]=='gracz' AND $_SESSION["pola"]["2,2"]=='gracz')OR($_SESSION["pola"]["0,1"]=='gracz' AND $_SESSION["pola"]["1,1"]=='gracz')) AND $_SESSION["pola"]["2,1"]==''){ $_SESSION["pola"]["2,1"] ='komputer'; }elseif($_SESSION["pola"]["1,0"]=='gracz' AND $_SESSION["pola"]["2,0"]=='gracz' AND $_SESSION["pola"]["0,1"]==''){ $_SESSION["pola"]["0,1"] ='komputer'; echo '7'; }elseif($_SESSION["pola"]["0,1"]=='gracz' AND $_SESSION["pola"]["2,1"]=='gracz' AND $_SESSION["pola"]["1,1"]==''){ $_SESSION["pola"]["1,1"] ='komputer'; }elseif((($_SESSION["pola"]["0,2"]=='gracz' AND $_SESSION["pola"]["2,2"]=='gracz')OR($_SESSION["pola"]["1,0"]=='gracz' AND $_SESSION["pola"]["1,1"]=='gracz')) AND $_SESSION["pola"]["1,2"]==''){ $_SESSION["pola"]["1,2"] ='komputer'; }elseif($_SESSION["pola"]["0,0"]=='gracz' AND $_SESSION["pola"]["2,2"]=='gracz' AND $_SESSION["pola"]["1,1"]==''){ $_SESSION["pola"]["1,1"] ='komputer'; }elseif($_SESSION["pola"]["2,0"]=='gracz' AND $_SESSION["pola"]["0,2"]=='gracz' AND $_SESSION["pola"]["1,1"]==''){ $_SESSION["pola"]["1,1"] ='komputer'; }elseif((($_SESSION["pola"]["0,0"]=='gracz' AND $_SESSION["pola"]["2,0"]=='gracz')OR($_SESSION["pola"]["1,1"]=='gracz' AND $_SESSION["pola"]["1,2"]=='gracz')) AND $_SESSION["pola"]["1,0"]==''){ $_SESSION["pola"]["1,0"] ='komputer'; }elseif($_SESSION["pola"]["2,0"]=='gracz' AND $_SESSION["pola"]["2,1"]=='gracz' AND $_SESSION["pola"]["2,2"]==''){ $_SESSION["pola"]["2,2"] ='komputer'; }elseif($_SESSION["pola"]["0,0"]=='gracz' AND $_SESSION["pola"]["1,0"]=='gracz' AND $_SESSION["pola"]["2,0"]==''){ $_SESSION["pola"]["2,0"] ='komputer'; }elseif($_SESSION["pola"]["0,0"]=='gracz' AND $_SESSION["pola"]["0,1"]=='gracz' AND $_SESSION["pola"]["0,2"]==''){ $_SESSION["pola"]["0,2"] ='komputer'; }elseif($_SESSION["pola"]["0,1"]=='gracz' AND $_SESSION["pola"]["0,2"]=='gracz' AND $_SESSION["pola"]["0,0"]==''){ $_SESSION["pola"]["0,0"] ='komputer'; }elseif($_SESSION["pola"]["2,1"]=='gracz' AND $_SESSION["pola"]["2,2"]=='gracz' AND $_SESSION["pola"]["2,0"]==''){ $_SESSION["pola"]["2,0"] ='komputer'; }elseif($_SESSION["pola"]["1,2"]=='gracz' AND $_SESSION["pola"]["2,2"]=='gracz' AND $_SESSION["pola"]["0,2"]==''){ $_SESSION["pola"]["0,2"] ='komputer'; }elseif($_SESSION["pola"]["0,2"]=='gracz' AND $_SESSION["pola"]["1,2"]=='gracz' AND $_SESSION["pola"]["2,2"]==''){ $_SESSION["pola"]["2,2"] ='komputer'; }elseif($_SESSION["pola"]["0,2"]=='gracz' AND $_SESSION["pola"]["1,1"]=='gracz' AND $_SESSION["pola"]["2,0"]==''){ $_SESSION["pola"]["2,0"] ='komputer'; }elseif($_SESSION["pola"]["2,0"]=='gracz' AND $_SESSION["pola"]["1,1"]=='gracz' AND $_SESSION["pola"]["0,2"]==''){ $_SESSION["pola"]["0,2"] ='komputer'; }elseif($_SESSION["pola"]["0,0"]=='gracz' AND $_SESSION["pola"]["1,1"]=='gracz' AND $_SESSION["pola"]["2,2"]==''){ $_SESSION["pola"]["2,2"] ='komputer'; }elseif($_SESSION["pola"]["1,1"]=='gracz' AND $_SESSION["pola"]["2,2"]=='gracz' AND $_SESSION["pola"]["0,0"]==''){ $_SESSION["pola"]["0,0"] ='komputer'; // } else{ $y=0; echo 'a'; $z=0; while($y==0){ $pierwsza = rand(0,2); $druga = rand(0,2); if($_SESSION["pola"]["".$pierwsza.",".$druga.""]==''){ $_SESSION["pola"]["".$pierwsza.",".$druga.""]='komputer'; //echo 'TU'.$pierwsza.' '.$druga; $y=1; } //echo 'Tta'.$pierwsza.' '.$druga; $z++; if($z==25){ break; } } if($y==0){ //echo 'tu zrobie'; } } } //$_SESSION['pola'] = $arrPola; } function rysuj_tabele($arrPola){ //print_r($arrPola); echo '<center><table><tbody>'; $y=1; foreach($arrPola as $key => $value){ if($y==1){ echo '<tr>'; } if(substr($value,0,1)=='W'){ echo '<td class="WIN">'; }else{ echo '<td class="'.$value.'">'; } if($value == 'gracz' OR $value=='Wgracz'){ echo '<span class="gracz">O</span>'; }elseif($value=='komputer' OR $value=='Wkomputer'){ echo '<span class="komputer">X</span>'; }else{ if($_SESSION['what']){ if($_SESSION['koniec']==0){ echo '<a href="main.php?act=postaw&pole='.$key.'">Postaw</a>'; } }else{ echo 'WYBIERZ CZYM GRASZ'; } } echo '</td>'; if($y==3){ $y=0; echo '</tr>'; } $y++; } echo '</tbody></table></center>'; } function sprawdz($arrPola){ if($_SESSION['koniec']!=1){ if($arrPola["0,0"]==$arrPola["0,1"] AND $arrPola["0,1"] == $arrPola["0,2"]){ if($arrPola["0,0"]!='' AND $arrPola["0,1"]!='' AND $arrPola["0,2"]!=''){ $arrPola["0,0"]='W'.$arrPola["0,0"]; $arrPola["0,1"]='W'.$arrPola["0,1"]; $arrPola["0,2"]='W'.$arrPola["0,2"]; $w=1; } } if($arrPola["1,0"]==$arrPola["1,1"] AND $arrPola["1,1"] == $arrPola["1,2"]){ if($arrPola["1,0"]!='' AND $arrPola["1,1"]!='' AND $arrPola["1,2"]!=''){ $arrPola["1,0"]='W'.$arrPola["1,0"]; $arrPola["1,1"]='W'.$arrPola["1,1"]; $arrPola["1,2"]='W'.$arrPola["1,2"]; $w=1; } } if($arrPola["2,0"]==$arrPola["2,1"] AND $arrPola["2,1"] == $arrPola["2,2"]){ if($arrPola["2,0"]!='' AND $arrPola["2,1"]!='' AND $arrPola["2,2"]!=''){ $arrPola["2,0"]='W'.$arrPola["2,0"]; $arrPola["2,1"]='W'.$arrPola["2,1"]; $arrPola["2,2"]='W'.$arrPola["2,2"]; $w=1; } } if($arrPola["0,0"]==$arrPola["1,0"] AND $arrPola["1,0"] == $arrPola["2,0"]){ if($arrPola["0,0"]!='' AND $arrPola["1,0"]!='' AND $arrPola["2,0"]!=''){ $arrPola["0,0"]='W'.$arrPola["0,0"]; $arrPola["1,0"]='W'.$arrPola["1,0"]; $arrPola["2,0"]='W'.$arrPola["2,0"]; $w=1; } } if($arrPola["0,1"]==$arrPola["1,1"] AND $arrPola["1,1"] == $arrPola["2,1"]){ if($arrPola["0,1"]!='' AND $arrPola["1,1"]!='' AND $arrPola["2,1"]!=''){ $arrPola["0,1"]='W'.$arrPola["0,1"]; $arrPola["1,1"]='W'.$arrPola["1,1"]; $arrPola["2,1"]='W'.$arrPola["2,1"]; $w=1; } } if($arrPola["0,2"]==$arrPola["1,2"] AND $arrPola["1,2"] == $arrPola["2,2"]){ if($arrPola["0,2"]!='' AND $arrPola["1,2"]!='' AND $arrPola["2,2"]!=''){ $arrPola["0,2"]='W'.$arrPola["2,2"]; $arrPola["1,2"]='W'.$arrPola["1,2"]; $arrPola["2,2"]='W'.$arrPola["2,2"]; $w=1; } } if($arrPola["0,0"]==$arrPola["1,1"] AND $arrPola["1,1"] == $arrPola["2,2"]){ if($arrPola["0,0"]!='' AND $arrPola["1,1"]!='' AND $arrPola["2,2"]!=''){ $w=1; $arrPola["0,0"]='W'.$arrPola["0,0"]; $arrPola["1,1"]='W'.$arrPola["1,1"]; $arrPola["2,2"]='W'.$arrPola["2,2"]; } } if($arrPola["0,2"]==$arrPola["1,1"] AND $arrPola["1,1"] == $arrPola["2,0"]){ if($arrPola["0,2"]!='' AND $arrPola["1,1"]!='' AND $arrPola["2,0"]!=''){ $arrPola["0,2"]='W'.$arrPola["0,2"]; $arrPola["1,1"]='W'.$arrPola["1,1"]; $arrPola["2,0"]='W'.$arrPola["2,0"]; $w=1; } } if($w==1){ $_SESSION['koniec']=1; } //print_r($arrPola); $_SESSION['pola'] = $arrPola; } } if(!$_SESSION['pola'] OR $_GET['act']=='reset'){ $_SESSION['koniec']=0; $Pola = array("0,0" => "", "0,1" => "", "0,2" => "", "1,0" => "", "1,1" => "", "1,2" => "", "2,0" => "", "2,1" => "", "2,2" => ""); $_SESSION['pola'] = $Pola; } if($_GET['act']=='sprawdz'){ postaw($_SESSION['pola']); } $Pola = $_SESSION['pola']; sprawdz($_SESSION['pola']); rysuj_tabele($_SESSION['pola']); //echo '<center><a href="main.php?set=kolko">O</a> <a href="main.php?set=krzyzyk">X</a>'; echo '<br /><a href="main.php?act=reset">Resetuj</a><br />'; //<a href="main.php?act=sprawdz">Sprawd\BC</a></center>'; ?>
Output for 4.3.2 - 5.4.32
<?php Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /in/dlWjS:1) in /in/dlWjS on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/dlWjS:1) in /in/dlWjS on line 2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Page title</title> <style type="text/css"> <!-- body{ background-color:#03a4ff; } td { background-color:#F2F238; width:150px; height:150px; text-align:center; } td.gracz{ background-color:#F8F8F8; } td.komputer{ background-color:#D5D5D5; } td.WIN{ background-color:#ff0e00; } span.gracz{ font-size:42px; } span.komputer{ font-size:42px; } ---> </style> <center><table><tbody><tr><td class=""><a href="main.php?act=postaw&pole=0,0">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=0,1">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=0,2">Postaw</a></td></tr><tr><td class=""><a href="main.php?act=postaw&pole=1,0">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=1,1">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=1,2">Postaw</a></td></tr><tr><td class=""><a href="main.php?act=postaw&pole=2,0">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=2,1">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=2,2">Postaw</a></td></tr></tbody></table></center><br /><a href="main.php?act=reset">Resetuj</a><br />
Output for 4.3.0 - 4.3.1
<?php Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cookie - headers already sent by (output started at /in/dlWjS:1) in /in/dlWjS on line 2 Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cache limiter - headers already sent (output started at /in/dlWjS:1) in /in/dlWjS on line 2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Page title</title> <style type="text/css"> <!-- body{ background-color:#03a4ff; } td { background-color:#F2F238; width:150px; height:150px; text-align:center; } td.gracz{ background-color:#F8F8F8; } td.komputer{ background-color:#D5D5D5; } td.WIN{ background-color:#ff0e00; } span.gracz{ font-size:42px; } span.komputer{ font-size:42px; } ---> </style> <center><table><tbody><tr><td class=""><a href="main.php?act=postaw&pole=0,0">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=0,1">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=0,2">Postaw</a></td></tr><tr><td class=""><a href="main.php?act=postaw&pole=1,0">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=1,1">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=1,2">Postaw</a></td></tr><tr><td class=""><a href="main.php?act=postaw&pole=2,0">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=2,1">Postaw</a></td><td class=""><a href="main.php?act=postaw&pole=2,2">Postaw</a></td></tr></tbody></table></center><br /><a href="main.php?act=reset">Resetuj</a><br />