echo is outputting unexpected result

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

echo is outputting unexpected result

Post by dsdsdsdsd »

hello; I have an echo statement which sends info to .swf file:

Code: Select all

<?php
{ echo ("&var=good");}
?>
the output that I am getting:
---------------------------------------------------
good<br/>
<b>blahh blahh <b>
</body>
</html>
--------------------------------------------------
any thoughts?

thanks
Shannon Burnett
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

many thoughts, but none about this subject.... :lol:
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

Post by dsdsdsdsd »

Groop I implore thee, my foonting turlingdromes.
And hooptiously drangle me with crinkly bindlewurdles.
Or I will rend thee in the gobberwarts with my burglecruncheon, see if I don't!

if you wrote this - very nice
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

What are you expecting it to do?
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

Nope, the Prostetnic Vogon Jeltz did.... :lol:
and it's awfull when a Vogon read poems....
as we all know :twisted: :twisted: :twisted:
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

Post by dsdsdsdsd »

I was expecting merely ' good ' as a response; ofcourse I can cut all the extra stuff away but nevertheless I would like to know why I am getting all that extra stuff
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

show me the rest of the code.. I'm a bit confused..

Good is being outputted isnt it?
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

Post by dsdsdsdsd »

hello phenom; here is my php code:
----------------------------------------------------
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<?
echo "$var=good";
?>
</body>
</html>
------------------------------------------------------
and the output is:
-------------------------------------
good<br/>
</body>
</html>
-------------------------------------

please note that in my earlier post I had also <b>blahh blahh <b> but that I have removed it

thanks
dsdsdsdsd
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

When you open the page and click source code

this is all you see?

good<br/>
</body>
</html>
dirtyoldgoat
Forum Newbie
Posts: 4
Joined: Fri Feb 06, 2004 4:37 pm

Post by dirtyoldgoat »

The only odd thing I see is that the '/' is in the wrong place for the <br>...

He doesn't have it placed in the source code for the php page, but the misplaced backslash could be jacking it up...
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I have no idea where he's getting this from

<br/>

........ or how it is generated
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Not sure what you're trying to do with echo "$var=good"; . Are you trying to output this?

Code: Select all

$var=good
&lt;/body&gt;
&lt;/html&gt;
If so you have to add a slash so PHP doesn't interpret it as a variable:

Code: Select all

<?php
echo "\$var=good"; 
?>
If thats not what you're trying to do, is this?

Code: Select all

<?php
$var = "Rating";
echo $var . "=good";
?>
Which would output:

Code: Select all

Rating =good&lt;br/&gt;
&lt;/body&gt;
&lt;/html&gt;
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

Post by dsdsdsdsd »

I apologize, I did not make myself clear;

echo "&var=good" is echoing to an .swf file;

in the .swf file I will end up with a variable called 'var' whose value should be 'good';

however I end up with 'var' having a value of
' good<br/>
</body>
</html> '

also I mistakingly posted '$var=...' earlier - should have been a '&', not a '$'
Post Reply