duan0708676887 2019-02-19 12:27
浏览 20

在输入字段上使用类属性声明值

again! I've already made an

echo "<input type='number' name='total' value='$employee->totalSalary($raise,$pay)' readonly='readonly'>";. 

But it says:

Notice: Undefined property: Employee::$totalSalary in C:\xampp\htdocs\salary.php on line

Though, I have this property:

$id1 = $_POST["id"];
$fname = $_POST["fname"];
$lname = $_POST["lname"];
$pay = $_POST["salary"];
$raise = $_POST["raise"];

$employee = new Employee($id1,$fname,$lname,$pay);

I have this function to get my total annual salary:

function totalSalary($raise,$salary){
        $raisePerc = $raise / 100;
        $annual = $salary * 12; 
        $annualTotal = ($annual * $raisePerc) + $annual;
        return $annualTotal;
    }

I want to display the total annual salary on the number/text field. Thank you for answering. :)

  • 写回答

1条回答 默认 最新

  • dongrao9454 2019-02-19 12:35
    关注

    the function arnt in the class so u can't use $employee->totalSalary

    class Employee {
    //set up other function ...
    
    
    public function totalSalary($raise,$salary){
            $raisePerc = $raise / 100;
            $annual = $salary * 12; 
            $annualTotal = ($annual * $raisePerc) + $annual;
            return $annualTotal;
        }
    }
    
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c