Jump to content

[SOLVED] PHP Heredoc Inside A Function - Not Working


jadedknight

Recommended Posts

I have seen examples (specifically in the book 'Learning PHP 5') of a heredoc inside a function, however when I attempt the same thing, I get an error:

 

Parse error: syntax error, unexpected $end in PATH\add_note.php on line 26

 

The error, I presume is because the PHP document is ending but the function? Or something else is not. Here is the code I am using.

 

<?php
function print_form() {
print <<< FORM
<form action="addnote_validate.php" method="post">
<label for="title">Title</label>
<input type="text" id="title" name="title" />

<label for="url">Related URL <span>(optional)</span></label>
<input type="text" id="url" name="url" />

<label for="content">Note</label>
<input type="text" id="note" name="note" />

<label for="tags">Tags <span>(seperated with a space)</span></label>
<input type="text" id="tags" name="tags" />

<input type="submit" value="Save Note"/>
</form>

FORM;
}
?>

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.