我在计算器的 div 中显示输入时遇到问题。它不显示任何内容。我究竟做错了什么?我对PHP很陌生,所以请尽可能多地解释,以便我可以从中学习。如果可能,那么该变量应该不断刷新,使其始终是最新的输入。这是我的代码,问题可以在代码的PHP部分找到:
HTML:
<!DOCTYPE HTML>
<html>
<head>
<title>Calculator</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script src="http://code.jquery.com/jquery-2.0.2.min.js"></script>
<script src="http://code.jquery.com/color/jquery.color.plus-names-2.1.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://ricostacruz.com/jquery.transit/jquery.transit.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div id="device">
<div class="row">
<div id="C" class="button">
C
</div>
<div id="MCR" class="button">
MCR
</div>
<div id="M+" class="button">
M+
</div>
<div id="M-" class="button">
M-
</div>
</div>
<div class="row">
<div id="7" class="button" >
7
</div>
<div id="4" class="button">
4
</div>
<div id="1" class="button">
1
</div>
<div id="0" class="button">
0
</div>
</div>
<div class="row">
<div id="8" class="button">
8
</div>
<div id="5" class="button">
5
</div>
<div id="2" class="button">
2
</div>
<div id="." class="button">
.
</div>
</div>
<div class="row">
<div id="9" class="button">
9
</div>
<div id="6" class="button">
6
</div>
<div id="3" class="button">
3
</div>
<div id="=" class="button">
=
</div>
</div>
<div class="row">
<div id="+" class="button">
+
</div>
<div id="-" class="button">
-
</div>
<div id="x" class="button">
x
</div>
<div id="/" class="button">
/
</div>
<div id="display">
<?php
var $input = "0";
function showInput() {
echo $input;
};
while () {
showInput();
};
?>
</div>
</div>
</div>
</body>
</html>
CSS:
body, html {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
}
#device {
width: 450px;
height: 400px;
background-color: #AB988B;
margin: 150px;
margin-top: 50px;
padding: 30px;
border-radius: 25px;
border: solid 10px #B06A3B;
padding-top: 100px;
}
#display {
width: 450px;
height: 75px;
background-color: #D4E7ED;
margin: auto;
border-radius: 5px;
margin-bottom: 30px;
top: 80px;
left: 190px;
position: absolute;
color: #B06A3B;
font-size: 25px;
line-height: 75px;
}
.button {
width: 65px;
height: 75px;
background-color: #7195A3;
border: solid 2px #EB8540;
color: #B06A3B;
font-size: 25px;
line-height: 75px;
margin-top: 15px;
margin-right: 17.5px;
text-align: center;
font-weight: 900;
font-family: arial;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
cursor: pointer;
}
.row {
display: inline-block;
}
jsFiddle: