Brocktoon Brocktoon - 1 year ago 118
PHP Question

Fatal error: Function name must be a string in C:\xampp\htdocs\display_discount.php on line 13

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"
<html xmlns="">
<title>Product Discount Calculator</title>
<link rel="stylesheet" type="text/css" href="main.css" />
<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 />


Answer Source

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


should be:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download