I’m trying to get the basic heredoc to work but I can’t seem to see what my problem is. Code below:
[php]<?php
$author = “eric”;
echo<<<_END
This is a headline
This is the first line.
This is the second line.
- Written by $author.
_END;
?>[/php]
I’ve tried writing it in VIM and pico on a Ubuntu VPS. I also tried writing it in notepad on XP and then SCPing it to the VPS.
The VPS is running PHP Version 5.3.2-1ubuntu4.5.
I’ve also tried copying and pasting the example from php.net below. I copied from Chrome in XP to GVIM, saved it and FTPed it to another account on Hostgator.
[php]<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
/* More complex example, with variables. */
class foo
{
var $foo;
var $bar;
function foo()
{
$this->foo = 'Foo';
$this->bar = array('Bar1', 'Bar2', 'Bar3');
}
}
$foo = new foo();
$name = ‘MyName’;
echo <<<EOT
My name is “$name”. I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital ‘A’: \x41
EOT;
?>[/php]
What am I missing? It can’t get it to work on 2 different hosts.