duan1396 2014-09-03 22:25
浏览 36
已采纳

致命错误:函数名称必须是第13行的C:\ xampp \ htdocs \ display_discount.php中的字符串

I'm learning PHP this semester and I'm both enjoying it and immediately lost a bit on my first real assignment. There are a few other similar questions but, because I'm new, I'm not able to extrapolate their answers to help with this.

I am getting the error in the title. The mission is to create POST code to handle all of the product description, price data, etc. I've added that code, but I'm getting the must be a string error on like 13 (under product description) but am unsure why.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Product Discount Calculator</title>
    <link rel="stylesheet" type="text/css" href="main.css" />
</head>
<body>
    <div id="content">
        <h1>This page is under construction</h1>

        <label>Product Description:</label>
        <span><?php echo $product_description = $_POST('product_desc'); ?></span><br /> (THIS IS LINE 13)

        <label>List Price:</label>
        <span><?php echo $list_price_formatted = $_POST('list_price'); ?></span><br />

        <label>Standard Discount:</label>
        <span><?php echo $discount_percent_formatted = $_POST('std_discount'); ?></span><br />

        <label>Discount Amount:</label>
        <span><?php echo $discount_formatted= $_POST('discount_amt'); ?></span><br />

        <label>Discount Price:</label>
        <span><?php echo $discount_price_formatted = $_POST('final_price'); ?></span><br />

        <p>&nbsp;</p>
    </div>
</body>
</html>
  • 写回答

2条回答 默认 最新

  • douxian0279 2014-09-03 22:27
    关注

    $_POST is not a function but an array. Functions are invoked with parameters between parentheses, arrays are queried with square brackets. Thus:

     $_POST('product_desc')
    

    should be:

     $_POST['product_desc']
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数