它工作正常,但只有在我的电脑上,只有在我的电脑上,突然它完全停止工作,我关闭并重新打开铬。现在它不会在我的会话中存储任何数据。 http://xeon.spskladno.cz/~filipt/Fourth.php
<?php
session_start();
print_r($_SESSION);
$num1=$_POST["num1"];
$num2=$_POST["num2"];
$action=$_POST["action"];
$memory=$_POST["memory"];
if($action=='+')
$vys=$num1+$num2;
if($action=='-')
$vys=$num1-$num2;
if($action=='*')
$vys=$num1*$num2;
if($action=='/')
$vys=$num1/$num2;
?>
<!DOCTYPE html>
<html><body>
<form action="Fourth.php" method="post">
Cislo1: <br>
<input type="number" name="num1" value="<?php echo $num1;?>" >
<br>
Cislo2: <br>
<input type="number" name="num2" value="<?php echo $num2;?>">
<br>
Akce: <br>
<select name="action" >
<option value="+">Scitani</option>
<option value="-">Odcitani</option>
<option value="*">Nasobeni</option>
<option value="/">Deleni</option>
</select>
<br>
Pocet ulozenych vypoctu:<br>
<input type="number" name="memory" value="<?php echo $memory;?>">
<br><br><br>
<input type="submit" value="Spocti">
</form>
</body>
</html><?php
if((strlen(trim($_POST["num1"]))==0)||(strlen(trim($_POST["num2"]))==0)||(strlen(trim($_POST["memory"]))==0))
die("Vyplnte prosim obe cisla a pocet ulozenych vypoctu.");
if($action=='+'){
echo "Vysledek prikaldu ",$num1,$action,$num2," je ",$vys;
}
if($action=='-'){
echo "Vysledek prikaldu ",$num1,$action,$num2," je ",$vys;
}
if($action=='*'){
echo "Vysledek prikaldu ",$num1,$action,$num2," je ",$vys;
}
if($action=='/'){
echo "Vysledek prikaldu ",$num1,$action,$num2," je ",$vys;
}
$string="$num1$action$num2=$vys";
array_push($_SESSION['vysledky'],$string);
$con=count($_SESSION['vysledky']);
if($con>$memory){
$rozdil=$con-$memory;
for($i=0; $i<$rozdil; $i++)
array_shift($_SESSION['vysledky']);
}
echo "<br>Ulozene vypocty:<br> ";
foreach ($_SESSION['vysledky'] as $value) {
echo "$value <br> ";
}
?>