Solved

What do these tages mean in php code or usage;  <<< EOFORMSTR  and later , EOFORMSTR    I have seen them in various example code from a PHP book.

Posted on 2006-07-08
14
566 Views
Last Modified: 2010-08-05
I realize that when I remove them from the Zend editor the rest of the
code seems ok ; except that when I do a debug I get then a 'parse error'
on line 35 where the <TABLE> tag begins; "what am I missing here"????

<?php
/****************************
 * Change email form page.*
 ***************************/

require_once('includes/emailpass_funcs.inc');
require_once('includes/login_funcs.inc');
if (!user_isloggedin()) {
      header("location: index.php");
 }
 
  if ($_POST['submit'] == "Change my confirmation") {
        $worked = user_change_email();
        if ($worked == 1) {
              $feedback_str = "<P class=\"errormess\">A confirmation" .
              "email has been sent to you.<\P>";
        } else {
              $feedback_str = "<P class=\"errormess\">$feedback<\P>";
    }
      
    }
      
   
    // ------------
    // DISPLAY FORM
    // ------------
   
    include_once('includes/header_footer.php');
    site_header('Change Email');
   
    // Superglobals don't work with heredoc
    $php_self = $_SERVER['PHP_SELF'];
   
    $form_str = <<< EOFORMSTR
    <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 ALIGN=CENTER
      WIDTH=621>
    <TR>
    <TD ROWSPAN=2><IMG WIDTH=15 HEIGHT=1
      SRC=../images/spacer.gif></TD>
    <TD WIDTH=606 HEIGHT=1><IMG WIDTH=606 HEIGHT=1
      SRC=../images/spacer.gif></TD>
    </TR>
    <TR>
     <TD>
    $feedback_str
    <P CLASS=left><B>Change your email address</B><BR>
    A confirmation email will be sent to you. <BR>
    <FORM ACTION="$php_self" METHOD="POST">
    <B>Password</B><BR>
    <INPUT TYPE="password" NAME="password1" VALUE="" SIZE="10"
        MAXLENGHT="15"><BR><BR>
    <B>New email</B> (required for confirmation)<BR>
    <INPUT TYPE="TEXT" NAME="new_email" VALUE="" SIZE="20"
        MAXLENGHT="35"><BR><BR>
    <INPUT TYPE="SUBMIT" NAME="submit" VALUE="Send my confirmation">
    </FORM>
    </TD>
    </TR>
    </TABLE>
    EOFORMSTR;

    echo  $form_str;
   
    site_footer();
   
    ?>
   
0
Comment
Question by:abelgarcia
  • 6
  • 3
  • 3
14 Comments
 
LVL 29

Expert Comment

by:TeRReF
ID: 17064485
Don't use space, so change:
$form_str = <<< EOFORMSTR
to
$form_str = <<<EOFORMSTR
0
 
LVL 29

Accepted Solution

by:
TeRReF earned 125 total points
ID: 17064489
It's called the heredoc.
It's a way to delimit strings. Especially suitable for longer strings. Read more about it here:
http://nl2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17064496
I have not seen that in php until today, but in FTP....

this line:
  $form_str = <<< EOFORMSTR
tells to assign to the variable $form_str   all the lines that follow that line until a line with EOFORMSTR is found

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17064499
I see TeRReF posted the document link, learned something new today (will help me ALOT) !!!
thanks TeRReF
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17064586
You're welcome ;)
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17067165
Grade B? Why? I answered your question didn't I?
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17067895
@ angelIII
Not really. My first answer actually dealed with that. The parse error was because of the space between <<< and EOFORMSTR

Right?

0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17069226
Oh, thanks!
0
 

Author Comment

by:abelgarcia
ID: 17078826
Actually with all respect due to TeRRef the 'space' ($form_str = <<< EOFORMSTR) in question did not solve my problem yet, not becuase it may not be
correct but becuase there is still something wrong with the code and I have not got it to appear in the editor as it should. If I dont get a parse error
the editor thinks that the script is not close and the closing tag ?> is not hightlighted as it should etc....
This is the first question I ask, perhaps I am not quite sure how the grading actually works I will have to be more careful.
If anyone is up to it could they point out what it is in the code example that is still in error. Thank you all...
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17079042
>the editor thinks that the script is not close and the closing tag ?> is not hightlighted as it should etc....
I am quite sure that the editor does not support the heredoc notation, what editor is it? can you check with it's documentation? can you test with a small test file:

<?php
$var =<<<EEEEEE
<test>hello</test>
EEEEEE;
print $var;
?>
0
 

Author Comment

by:abelgarcia
ID: 17096134
<?php
$var =<<<EEEEEE
<test>hello</test>
EEEEEE;
print $var;
?>

this script works fine..
0
 

Author Comment

by:abelgarcia
ID: 17102903
ok thanks everyone; the problem did have to do with spaces but in the closing
tag...

 </TD>
 </TR>
 </TABLE>
 
(I had a space here)EOREGSTR  
echo $reg_str;
 
site_footer();
 
 ?>
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question