johnmerlino1 Posted July 26, 2014 Share Posted July 26, 2014 I have following script: <?php $tireqty = isset($_POST['tireqty']) ? $_POST['tireqty'] : null; $oilqty = isset($_POST['oilqty']) ? $_POST['tireqty'] : null; echo "<p>order processed on " . date("F d, Y g:sA") . "</p>"; if($tireqty){ echo "tire quantity " . $tireqty; } if($oilqty){ echo "oil quantity " . $oilqty; } echo <<<theEnd Thank you for visiting our store and buying $tireqty tires and 3 $oilqty. Have a very nice day. theEnd; ?> Aptana shows error for the last "?>" as soon as I add the heredocs and when running it in browser, I get the following error: Parse error: syntax error, unexpected $end in /home/myuser/public_html/shopwithus.com/controllers/orders_controller.php on line 20 What might I be doing wrong? Link to comment https://forums.phpfreaks.com/topic/290125-heredocs-not-working/ Share on other sites More sharing options...
fastsol Posted July 26, 2014 Share Posted July 26, 2014 In my opinion, using heredocs in the first place is the problem. The syntax is always a pain to get right. What's so hard with doing this echo 'Thank you for visiting our store and buying '.$tireqty.' and 3 '.$oilqty.'. Have a very nice day'; Link to comment https://forums.phpfreaks.com/topic/290125-heredocs-not-working/#findComment-1486197 Share on other sites More sharing options...
trq Posted July 27, 2014 Share Posted July 27, 2014 Your closing theEnd needs to be at the start of the line. Link to comment https://forums.phpfreaks.com/topic/290125-heredocs-not-working/#findComment-1486217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.