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
564 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
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…

743 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

15 Experts available now in Live!

Get 1:1 Help Now