Forum Moderators: coopster

Message Too Old, No Replies

novice question on includes - can't seem to get it working

in this instance

         

javahava

8:13 am on Oct 13, 2005 (gmt 0)

10+ Year Member



hi there,

sorry for the silly question, as i'm just learning php but can't quite figure this out. am trying to place an include file in the statement below:

---------------

echo <<<End
<tr><td >blah blah</td></tr>

<? include("include-file.php");?>

<tr><td >blah blah</td></tr>
<table>
End;
$script = $_SERVER['PHP_SELF'];
echo <<<End
<form action="$script" method="POST">
End;

-------------------------

The include file doesn't seem to be working though. I'm sure this is a silly syntax error - do you see what i'm doing wrong? Many many thanks!

omoutop

8:55 am on Oct 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi!

try this instead:

<? include "include-file.php";?>

omoutop

8:55 am on Oct 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



r u sure the file u wanna include is in the same path with ur script?

dreamcatcher

10:00 am on Oct 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don`t use the heredoc format myself, but do you need the PHP tags inside the echo? Maybe someone else can clear that up.

Have you tried:


echo <<<End
<tr><td >blah blah</td></tr>

include("include-file.php");

<tr><td >blah blah</td></tr>
<table>
End;
$script = $_SERVER['PHP_SELF'];
echo <<<End
<form action="$script" method="POST">
End;

dc

killroy

12:26 pm on Oct 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You cannot place PHP statements inside HereDoc (as far as I know).

Try this instead (PS, "End" might not be the best termination word):

echo <<<EOT
<tr><td >blah blah</td></tr>

EOT;
include("include-file.php");
echo <<<EOT

<tr><td >blah blah</td></tr>
<table>
End;
$script = $_SERVER['PHP_SELF'];
echo <<<End
<form action="$script" method="POST">
EOT;

sonjay

12:27 pm on Oct 13, 2005 (gmt 0)

10+ Year Member



You need to close out of the HEREDOC syntax before using the include:

echo <<<End
<tr><td >blah blah</td></tr>
End;

include("include-file.php");

echo <<<End
<tr><td >blah blah</td></tr>
<table>
End;
$script = $_SERVER['PHP_SELF'];
echo <<<End
<form action="$script" method="POST">
End;

javahava

6:49 pm on Oct 13, 2005 (gmt 0)

10+ Year Member



thanks a lot - that did the trick!