Re: Strange output from echo statement
From: 2metre (2metre_at_xxxhersham.net)
Date: 07/27/04
- Next message: prasanna: "Problem in sending mail"
- Previous message: R. Rajesh Jeba Anbiah: "Re: How can I get the message-body ?"
- In reply to: ScareCrowe: "Strange output from echo statement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 27 Jul 2004 11:44:36 +0000 (UTC)
ScareCrowe wrote:
> Whenever I try to print a string and a variable together I get incorrect
> output. After echoing the variable the rest of the line is ignored.
> //eg.
> $var1 = "test";
> echo "This is a " . $var1 . "! This is only a " . $var1;
> //returns:
> This is a test
> //instead of
> This is a test! This is only a test.
>
What version of PHP are you using?
I cut and pasted your code into a page (on a server running v4.3.4) and
it returned the full string as it should.
BTW if you are keeping the variables outside the strings, use single
quotes instead of double quotes - this will prevent PHP from having to
parse the contents of the string. Alternatively you could have written:
echo "This is a $var1! This is only a $var1";
- Next message: prasanna: "Problem in sending mail"
- Previous message: R. Rajesh Jeba Anbiah: "Re: How can I get the message-body ?"
- In reply to: ScareCrowe: "Strange output from echo statement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|