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
565 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now