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 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题