heardoc problem

heardoc problem

am 06.12.2007 16:26:24 von jpsebasti

Anyone see a problem with this code?

$login_error=<<
Database Login Error

Database Login Error




EOL;
echo "$login_error";
?>

When I attempt to run it at the command line
C:\ php t.php

I get the following error:
PHP Parse error: syntax error, unexpected $end in C:\Sebastian\pbuuc
\auction\t.php on line 12

Re: heardoc problem

am 06.12.2007 16:39:08 von Janwillem Borleffs

JP schreef:
> When I attempt to run it at the command line
> C:\ php t.php
>
> I get the following error:
> PHP Parse error: syntax error, unexpected $end in C:\Sebastian\pbuuc
> \auction\t.php on line 12
>

Perhaps the file contains control characters originating from your
editor (word?). When you have access to a *nix platform, try to clean
the file with the dos2unix utility.

If you don't have access to this utility, but your editor supports
exports to ascii text or utf-8 encoding, use that.


JW

Re: heardoc problem

am 06.12.2007 16:50:42 von jpsebasti

I use the VIM editor on Windows (VI for Windows) so not sure that I
have any invalid characters since other scripts that I edit with same
editor work just fine.

Anyway, I tried the following:

created a new t.php file containing the following
$tst = << test
EOL;
echo "$test\n";
?>

One file, I created in VIM and got the same error when executing.
Then, I created a new file with Notepad with the same text above.
That one runs
with no problems. So looks like for heardocs, there is some weirdness
with using the VIM
editor perhaps!



On Dec 6, 10:39 am, Janwillem Borleffs wrote:
> JP schreef:> When I attempt to run it at the command line
> > C:\ php t.php
>
> > I get the following error:
> > PHP Parse error: syntax error, unexpected $end in C:\Sebastian\pbuuc
> > \auction\t.php on line 12
>
> >
>
> Perhaps the file contains control characters originating from your
> editor (word?). When you have access to a *nix platform, try to clean
> the file with the dos2unix utility.
>
> If you don't have access to this utility, but your editor supports
> exports to ascii text or utf-8 encoding, use that.
>
> JW

Re: heardoc problem

am 06.12.2007 19:33:37 von Csaba

"JP" wrote in message
news:f9c03885-dfe5-4632-a260-9203a07176cf@w34g2000hsg.google groups.com...
> Anyone see a problem with this code?
>
> > $login_error=<< >
> Database Login Error
>
> Database Login Error


>
>
> EOL;
> echo "$login_error";
> ?>
>
> When I attempt to run it at the command line
> C:\ php t.php
>
> I get the following error:
> PHP Parse error: syntax error, unexpected $end in C:\Sebastian\pbuuc
> \auction\t.php on line 12

Which of the lines is line 12?

R.

Re: heardoc problem

am 06.12.2007 19:54:29 von Thomas Mlynarczyk

Also sprach JP:

> Anyone see a problem with this code?

> > $login_error=<< >
> Database Login Error
>
> Database Login Error


>
>
> EOL;
> echo "$login_error";
>>

Yes. It should be ?> at the end, not just >.

Greetings,
Thomas

--
C'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)

Re: heardoc problem

am 06.12.2007 20:08:41 von luiheidsgoeroe

On Thu, 06 Dec 2007 19:54:29 +0100, Thomas Mlynarczyk =

wrote:

> Also sprach JP:
>
>> Anyone see a problem with this code?
>
>> >> $login_error=3D<< >>
>> Database Login Error
>>
>> Database Login Error


>>
>>
>> EOL;
>> echo "$login_error";
>>>
>
> Yes. It should be ?> at the end, not just >.

That's just a problem with your newsreader, the ? is (well, was before t=
he =

quote) actually there.
-- =

Rik Wasmus

Re: heardoc problem

am 06.12.2007 20:11:37 von luiheidsgoeroe

On Thu, 06 Dec 2007 16:26:24 +0100, JP wrote:

> Anyone see a problem with this code?
>
> > $login_error=3D<< >
> Database Login Error
>
> Database Login Error


>
>
> EOL;
> echo "$login_error";
> ?>
>
> When I attempt to run it at the command line
> C:\ php t.php
>
> I get the following error:
> PHP Parse error: syntax error, unexpected $end in C:\Sebastian\pbuuc
> \auction\t.php on line 12

No errors running a copy / paste of the code here. Are you sure this is =
=

exactly as it is in the file? There should be no whitespace whatsoever =

before the EOL;, which is quite a common mistake when one want to proper=
ly =

indent code...
-- =

Rik Wasmus

Re: heardoc problem

am 06.12.2007 22:03:11 von Thomas Mlynarczyk

Also sprach Rik Wasmus:

>> Yes. It should be ?> at the end, not just >.

> That's just a problem with your newsreader, the ? is (well, was
> before the quote) actually there.


Hm. Indeed, it is there when I look at the message's source code. Which OE
bug is this? I thought with OE-QuoteFix, OE was more or less usable?

Greetings,
Thomas

--
C'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)

Re: heardoc problem

am 06.12.2007 22:18:33 von luiheidsgoeroe

On Thu, 06 Dec 2007 22:03:11 +0100, Thomas Mlynarczyk
wrote:

> Also sprach Rik Wasmus:
>
>>> Yes. It should be ?> at the end, not just >.
>
>> That's just a problem with your newsreader, the ? is (well, was
>> before the quote) actually there.
>
>
> Hm. Indeed, it is there when I look at the message's source code. Which
> OE
> bug is this? I thought with OE-QuoteFix, OE was more or less usable?

Don't know which bug it is, but it seems actually to be a problem
introduced by OE Quotefix. Disabling 'standardized indentation' solves it
(this is the settings that alters all quoting characters to your preferred
quoting character).

--
Rik Wasmus