0

php代码错误,此代码不断使用未定义的常量错误..请帮助

< ? php
$d = 1;
$a = $_POST[keya];
$b = $_ POST[keyb];
$c = $_POST[keyc];
$d = $a + $b + $c;
echo $d;
 ? >
4

2 回答 2

0
$d = 1;
$a = $_POST['keya'];
$b = $_POST['keyb'];
$c = $_POST['keyc'];
$d = $a + $b + $c;
echo $d;

您应该在 POST 中使用字符串键

于 2013-03-20T12:07:39.380 回答
0

您需要检查表单是否已提交并添加引号:

<?php
if(!empty($_POST)) {
    $d = 1;
    $a = $_POST['keya'];
    $b = $_POST['keyb'];
    $c = $_POST['keyc'];
    $d = $a + $b + $c;
    echo $d;
}
?>
于 2013-03-20T12:08:48.647 回答