Jump to content

heredocs not working


johnmerlino1
Go to solution Solved by trq,

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.