In public/quote.php, I have a line:

render("quote.php", ["price"=>$s["price"]);

Then in template.php, I try to print:

print("Price: " . $s["price"]);

but I keep getting this error:

Array to string conversion in /home/jharvard/vhosts/pset7/templates/quote.php on line 5

What am I doing wrong?

  • 1
    is this the line 5 code for quote.php? render("quote.php", ["price"=>$s["price"]);
    – lethaljd
    Jan 14 '15 at 18:27
  • 1
    There is a missing close bracket in the render call, don't think this is going to help though.
    – wallek876
    Jan 14 '15 at 21:02
  • Firstly the line should be render("quote.php", ["price" => $s["price"]]);. If you passed the value to the template with the name "price", you should access it like this print("Price: ", $price); Jan 15 '15 at 6:16
  • THank you. Christopher Clarke, can you please explain how passing in "price" in double quotes gets changed to the variable $price?
    – ytma
    Jan 15 '15 at 15:32

You must log in to answer this question.

Browse other questions tagged .