我在计算器中显示div中的输入时遇到问题。它不显示任何东西。我究竟做错了什么?我对PHP很新,所以请尽可能地解释一下,以便我可以从中学习。如果可能的话,那么变量应该不断刷新,以便它始终是最新的输入。这是我的代码,这个问题可以在代码的PHP部分中找到:在div中显示PHP变量
HTML:
CalculatorC
MCR
M+
M-
7
4
1
0
8
5
2
.
9
6
3
=
+
-
x
/
var $input = "0";
function showInput() {
echo $input;
};
while() {
showInput();
};
?>
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:
2013-07-29
Bart
+2
的jsfiddle不是为PHP的工作工作的例子。使用http://phpfiddle.org/ –
+3
您需要了解PHP是服务器端语言。因此,它不像你所描述的那样工作。您可能更感兴趣使用客户端语言,如JavaScript。 –
+1
你的PHP代码应该触发至少一个解析错误。看起来你混淆了Web开发中涉及的几种语言。你真的在你的电脑中安装了PHP吗? –