1
benlau
"Here document" syntax fail in custom block
  • 2004/4/25 8:32

  • benlau

  • Just popping in

  • Posts: 29

  • Since: 2004/3/7 1


Hi,

I have created a custom block(PHP). In the block , it has contained a echo statement with using "here document syntax":

echo <<< EOF
This uses the "here document" syntax to output data.
EOF;

However , it was fail to eval, with that error msg:

Parse error: parse error in //class/xoopsblock.php(146) : eval()'d code on line 3

It is quite strange that It should has no problem to write this kind of syntax to be evaluated by eval(). Any one has method to solve it? Thanks for any help.

2
JackJ
Re: "Here document" syntax fail in custom block
  • 2004/4/25 9:12

  • JackJ

  • Community Support Member

  • Posts: 747

  • Since: 2003/8/31


I am not a coder, but I know this kind of syntax works for an include and say for a banner for example

for an include single quotes are used i.e

include('here document');

this for an echo

echo xoops_getbanner();

With custom blocks you don't include the phptags, but you may know that already

If you post more of the code you are using perhaps a coder/developer will pick up on it..

3
Dave_L
Re: "Here document" syntax fail in custom block
  • 2004/4/25 10:09

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


I was able to duplicate the problem. What happens is that trailing whitespace seems to get trimmed, so PHP doesn't see the proper end of the here-document.

A workaround is to add at least one line afterwards:

echo <<< EOF
Hello, World!
EOF;
// dummy line to ensure heredoc is terminated

4
benlau
Re: "Here document" syntax fail in custom block
  • 2004/4/25 12:27

  • benlau

  • Just popping in

  • Posts: 29

  • Since: 2004/3/7 1


Putting a dummy line at the end has solved the problem.

Thanks you all!!

Login

Who's Online

271 user(s) are online (71 user(s) are browsing Support Forums)


Members: 0


Guests: 271


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits