Page 1 of 1
heredoc problem
Posted: Fri Aug 04, 2006 1:08 am
by omidkamangar
Hi ,
As I am new to PHP programming I have got a problem with heredoc style:
When I write a piece of code like this :
Code: Select all
$str = <<<BOT
This is text
in heredoc notation
BOT;
//-------------
echo $str;
I get an error message.
Posted: Fri Aug 04, 2006 1:14 am
by Luke
Have you looked at this? (not trying to be condescending, just wondering)
http://us2.php.net/manual/en/language.t ... ax.heredoc
Re: heredoc problem
Posted: Fri Aug 04, 2006 1:18 am
by Christopher
omidkamangar wrote:I get an error message.
What is the error message?
Posted: Fri Aug 04, 2006 7:38 am
by feyd
"BOT" must be the first characters on the line it's on. No whitespace or anything can lead it. Some systems have problems if there is a space after the declaration too: "<<<BOT"
Posted: Fri Aug 04, 2006 12:40 pm
by omidkamangar
This is the error message I get :
Code: Select all
Parse error: syntax error, unexpected $end in E:\xampp\htdocs\shahoo\test.php
Re: heredoc problem
Posted: Fri Aug 04, 2006 12:42 pm
by RobertGonzalez
omidkamangar wrote:Hi ,
As I am new to PHP programming I have got a problem with heredoc style:
When I write a piece of code like this :
Code: Select all
$str = <<<BOT
This is text
in heredoc notation
BOT;
//-------------
echo $str;
I get an error message.
It needs to be...
Code: Select all
$str = <<<BOT
This is text
in heredoc notation
BOT;
echo $str;
See how BOT is all the way to the left and is the only thing on its line? That is how heredoc works.