Results 1 to 10 of 11
I'm running PHP4 and for some reason, I can't get here doc strings to work. Here's what I have
Code:
<?php echo <<<EOT
A sentence
spanning in multiple
lines.
EOT
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 05-23-2003 #1Linux Engineer
- Join Date
- Nov 2002
- Location
- Queens, NY
- Posts
- 1,319
Basic syntax
I'm running PHP4 and for some reason, I can't get here doc strings to work. Here's what I have
As far as I'm concerned, I'm following the rules of the language by specifiying the identifiers and the closing identier stands alone in a newline. Any ideas why I'm having parsing errors?Code:<?php echo <<<EOT A sentence spanning in multiple lines. EOT ?>
The best things in life are free.
- 05-24-2003 #2Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
You haven't included a semicolon after EOT, right? That could be the error.
- 05-24-2003 #3Linux Engineer
- Join Date
- Apr 2003
- Location
- Sweden
- Posts
- 796
Why are you printing out text with EOT..do like this..
If you want to handle chunks of text or arrays use for or while loops for that.Code:<?php echo "Hello World \n"; echo "Printing another line on a line under \n"; echo "Printing this text on the same line"; ?>
Regards
Regards
Andutt
- 05-24-2003 #4Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
Well, it _is_ easier to write heredocs instead of doing such things.
- 05-25-2003 #5Linux Engineer
- Join Date
- Apr 2003
- Location
- Sweden
- Posts
- 796
No its not good programming....
Regards
Andutt
- 05-26-2003 #6Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
Now that depends on what programming language you're using. In shell scripting, it's most certainly good programming, and I can't say that there's anything wrong with it in PHP either. What do you have against it? In PHP, it's just another way of quoting, and there's not anything wrong with quoting.
- 05-26-2003 #7Linux Engineer
- Join Date
- Nov 2002
- Location
- Queens, NY
- Posts
- 1,319
Sorry for the late reponse but after checking my code, there is a semi colon after the closing identifer EOT.
The best things in life are free.
- 05-26-2003 #8Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
Are you sure? I just tried the following, and it worked perfectly for me.
Code:<?php echo <<<EOT Test Test Test EOT; ?>
- 05-26-2003 #9Linux Engineer
- Join Date
- Nov 2002
- Location
- Queens, NY
- Posts
- 1,319
Well here's the thing. I installed the php4 package from debian. I double checked to see that this was v4 instead of v3 since this is only supported in v4. I'm using apache to look at this since I don't have the command line interpreter installed on the machine. Looking through the file httpd.conf, everything seems to be in place regarding php4 so I don't know what the problem is. Could it be that there is an option to turn this on during installation and that Debian's package left out this option?
The best things in life are free.
- 05-26-2003 #10Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
I wouldn't think so, but who knows? Stranger things have happened, after all. Maybe you should try to install it from source instead?


Reply With Quote
