php 控制div显示_在div中显示PHP变量

本文档探讨了一个PHP初学者在尝试在HTML页面的div中显示PHP变量时遇到的问题。代码示例中,作者误将PHP代码与JavaScript混淆,导致无法正确显示输入。评论区提供了关于PHP作为服务器端语言的解释,建议使用JavaScript进行客户端实时更新。
摘要由CSDN通过智能技术生成

我在计算器中显示div中的输入时遇到问题。它不显示任何东西。我究竟做错了什么?我对PHP很新,所以请尽可能地解释一下,以便我可以从中学习。如果可能的话,那么变量应该不断刷新,以便它始终是最新的输入。这是我的代码,这个问题可以在代码的PHP部分中找到:在div中显示PHP变量

HTML:

Calculator

C

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吗? –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值