Forum Moderators: coopster

Message Too Old, No Replies

Heredoc problems ($end errors)

         

supermanjnk

3:32 pm on Apr 2, 2007 (gmt 0)

10+ Year Member



I'm running PHP Version 5.0.3 on IIS 6 (Windows server 2003) and i'm having some trouble with heredoc. Here is the code that I currently have:
<?
$here = <<<DOC
asdf
asdf
asdf
DOC;
?>

And here is the error message I'm getting
Parse error: syntax error, unexpected $end in D:\web\example.com\include\summaryCustomerMail.php on line 4

I've tried numerous sample codes, but I cannot get this working.

[edited by: eelixduppy at 5:19 pm (utc) on April 2, 2007]
[edit reason] exemplified error [/edit]

joelgreen

4:22 pm on Apr 2, 2007 (gmt 0)

10+ Year Member



Try adding empty line at the end of the script (i.e. after?>)

supermanjnk

4:38 pm on Apr 2, 2007 (gmt 0)

10+ Year Member



All that does is increment the error line by one for each line after?>

whoisgregg

6:23 pm on Apr 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only thing that stands out to me is the use of short open tags [php.net] ("<?" instead of "<?php"). Switch to the normal form just in case it's the true culprit.

supermanjnk

7:58 pm on Apr 2, 2007 (gmt 0)

10+ Year Member



I've thought of that aswell, regardless of what I do, it doesn't work. Is it an IIS thing? I can take the same code, on a development linux box running apache, and it works fine, so I know the code is valid.

eelixduppy

8:08 pm on Apr 2, 2007 (gmt 0)



From the documentation:

It is very important to note that the line with the closing identifier contains no other characters, except possibly a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs after or before the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by your operating system. This is \r on Macintosh for example. Closing delimiter (possibly followed by a semicolon) must be followed by a newline too.

If this rule is broken and the closing identifier is not "clean" then it's not considered to be a closing identifier and PHP will continue looking for one. If in this case a proper closing identifier is not found then a parse error will result with the line number being at the end of the script.

[php.net...]

Make sure everything is ok here, as well. Make sure there is no whitespace on that line, etc...

supermanjnk

2:53 pm on Apr 4, 2007 (gmt 0)

10+ Year Member



Thanks for the link, but i've looked at that multiple times, and like I said, It works fine under my development linux box, so I know the syntax is correct.
just not under my server 2003, iis 6 box.

joelgreen

3:35 pm on Apr 4, 2007 (gmt 0)

10+ Year Member



Is it the same file you are using in linux/windows?

Linux and Windows have different line break characters. So potentially file with ending line \n could cause such error (\r\n expected). Maybe php module for IIS is so picky.