PHP Heredoc help

pushVTEC

Senior member
Aug 30, 2003
265
0
0
Well I'm trying to use the php echo heredoc to print out some html and it wont work. I have a feeling it's because it needs CRLF after the EOHTML; but I saved it as both a unix and windows file (unix uses LF and windows CRLF correct) so why wouldn't it work?



I use textpad, and htmlkit. When I paste some examples it works fine, but when I try to do the exact same thing and type it it doesn't work.
 

pushVTEC

Senior member
Aug 30, 2003
265
0
0
Ok i'm sure it's because before the EOHTML there is just a CR but no LF. I used html kit's mini hex viewer and right before the EOHTML; I get a 0d (CR) but then it goes straight to the E and doesn't do the line feed (0A) anyone know how I can insert a LF using html kit or textpad?
 

stndn

Golden Member
Mar 10, 2001
1,886
0
0
Why do you have double switch for the same case?

--- attach code here ---
switch($state){
case "OH":
switch($state){
case "OH":
--- attach code here ---

btw, i don't think the heredoc matter whether you're using CRLF or CR only.
That's because heredoc will print whatever is at the beginning until it reaches the matching
<<<EOWHATEVER

which, i believe, must start at a new line, column zero, and does not end with semicolon?

edit: apparently, i was somewhat wrong. Quote from php manual:
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.
 

pushVTEC

Senior member
Aug 30, 2003
265
0
0
Yeah that double switch was a typo, ignore that there's only one switch statement. So anyone know how to insert the CRLF, I want to use heredoc because escaping out of the php or just echoing it manually would be a pain in the ass, because in the end i'm gonna have a lot of switch statements.
 

statik213

Golden Member
Oct 31, 2004
1,654
0
0
Originally posted by: pushVTEC
Well I'm trying to use the php echo heredoc to print out some html and it wont work. I have a feeling it's because it needs CRLF after the EOHTML; but I saved it as both a unix and windows file (unix uses LF and windows CRLF correct) so why wouldn't it work?



I use textpad, and htmlkit. When I paste some examples it works fine, but when I try to do the exact same thing and type it it doesn't work.

You shouldn't have to worry abt the line endings as long as they are consistent for your platform, i.e. \n for *nix, \r\n for Win, \r for mac.


 

pushVTEC

Senior member
Aug 30, 2003
265
0
0
Well I know that you MUST have a CRLF before the end EOHTML; and mine doesn't, it just has the 0D (CR) but no LF (0A) That's the only way I can see why it wouldn't work. Everything else in my code looks correct.