I have been trying to teach myself PHP. I installed PHP with the install for AppServ on Windows(just reference info). When I tried to see if I could get a proper output I was having trouble. This is what I used that showed the right results, but according to all the references I have seen the syntax is wrong.

<HTML>

<HEAD>
<TITLE> MY FIRST PHP PAGE </TITLE>
</HEAD>

<BODY
<?php echo?> "Hello World!" <br> "Hello World"
<?php print?><br> "Hello Indiana!"
</BODY>

</HTML>

If I enter this:

<HTML>

<HEAD>
<TITLE> MY FIRST PHP PAGE </TITLE>
</HEAD>

<BODY
<?php echo "Hello World!" <br> "Hello World"?>
<?php print<br> "Hello Indiana!" ?>
</BODY>

</HTML>

I get this as an outcome:
"Hello World"?> "Hello Indiana!"?>

Can anyone help me understanding why I am having this problem.

Recommended Answers

All 10 Replies

Member Avatar for rajarajan2017
<HTML>

<HEAD>
<TITLE> MY FIRST PHP PAGE </TITLE>
</HEAD>

<BODY
<?php 
	echo "Hello World! <br/> Hello World";
?>
<?php print "<br/>Hello Indiana!" ?>
</BODY>

</HTML>

you can directly use the <html> commands within echo and print. Above shows you the correct output.

Even your syntax is not proper other texts are recognised by php.

This was my output after making the changes you suggested. I even copied and pasted each line after the number to make sure that I had it correct.

"Hello World"; ?>

It doesn't even shoe the "I love Indiana" at all.

Member Avatar for rajarajan2017

you are running your file with localhost with the file extension of php right? If yes the above will not be the output. I had tested here.

Yes, I run it out of Notepad++ and the file is save with the .php. I'm still getting the wrong results. Could there be anything else that could cause this?

Member Avatar for rajarajan2017

No idea! if you have phpadmin then it will show the output.

Thank you for the help you could provide :)

<HTML>

<HEAD>
<TITLE> MY FIRST PHP PAGE </TITLE>
</HEAD>

<BODY
<?php echo "Hello World<br>Hello World
Hello Indiana!"; ?>
</BODY>

</HTML>

With that code it only output one Hello World,the rest looks good.
But the ; ?> at the end is still.

i dont know dude maybe there something wrong with your PHP, coz there's nothing wrong with the code

make it even more simple,

<HTML>
<HEAD>
<TITLE> MY FIRST PHP PAGE </TITLE>
</HEAD>
<BODY>
<?php 
        echo "Hello World!";
	echo "<br />"; 
	echo "Hello World";
	echo "<br />"; 
	echo "Hello Indiana";
?>
</BODY>
</HTML>

OR

<HTML>

<HEAD>
<TITLE> MY FIRST PHP PAGE </TITLE>
</HEAD>
<BODY>
<?php echo "Hello World!"."<br>". "Hello World"?>
<?php print "<br>". "Hello Indiana!" ?>
</BODY>
</HTML>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.