PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
omidkamangar
Forum Newbie
Posts: 16 Joined: Sun Jul 30, 2006 2:51 pm
Post
by omidkamangar » Fri Aug 04, 2006 1:08 am
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.
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Fri Aug 04, 2006 1:18 am
omidkamangar wrote: I get an error message.
What is the error message?
(#10850)
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 04, 2006 7:38 am
"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"
omidkamangar
Forum Newbie
Posts: 16 Joined: Sun Jul 30, 2006 2:51 pm
Post
by omidkamangar » Fri Aug 04, 2006 12:40 pm
This is the error message I get :
Code: Select all
Parse error: syntax error, unexpected $end in E:\xampp\htdocs\shahoo\test.php
Last edited by
omidkamangar on Sat Aug 05, 2006 10:12 am, edited 1 time in total.
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Fri Aug 04, 2006 12:42 pm
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.