grahamgr3 Posted October 8, 2014 Share Posted October 8, 2014 In Chapter 11 in the sending email script called email.php, the $_POST['name'] and $_POST['comments'] in the $body variable are wrapped in curly braces. Why are there curly braces around them. See the code below. if ($_SERVER['REQUEST_METHOD'] == 'POST'){ if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comments'])){ $body = "Name: {$_POST['name']}\n\nComments: {$_POST['comments']}"; $body = wordwrap($body, 70); } } Link to comment Share on other sites More sharing options...
Larry Posted October 8, 2014 Share Posted October 8, 2014 The curly braces prevent syntax errors from occurring. Link to comment Share on other sites More sharing options...
grahamgr3 Posted October 8, 2014 Author Share Posted October 8, 2014 So what should I watch for to know when to put curly braces around $_POST variables, is it only when using the mail function. Link to comment Share on other sites More sharing options...
Larry Posted October 10, 2014 Share Posted October 10, 2014 No, it's anytime you use $array['index'] within a double-quote string. Link to comment Share on other sites More sharing options...
Recommended Posts