views:

79

answers:

5
<html>

<!--HTML-->
<head><title>a quick test</title></head>
<body>a quick test</body>

<p>javascript</p>

<!--javascript-->
<p><script>
document.write("hello world")
</script></p>

<p>php</p>

<!--php-->
<?php
Echo "hello world";
?>

</html>

The Hello world works for javascript but not in php, what gives? Any suggestions or obvious errors?

thanks

A: 

try making your echo lowercase

swnsn
PHP functions and language constructs (like echo) are case-insensitive.
Marc B
+4  A: 

Are you saving this file with a .php file extension? PHP code will not execute within a normal .html file.

Dan D.
Correct - unless you add it in .htaccess or similar.
alex
thanks, glad it was an easy fix.
DanLeaningphp
@DanLeaningphp: Please mark my answer as accepted (by clicking the check mark to the left) if it was the answer to the question. Thanks!
Dan D.
A: 

If you view source, can you read your PHP? Perhaps your environment is set up wrong.

What does <?php phpinfo(); ?> yield?

alex
A: 

To be w3 valid by the way, your body tag should end before the ending html-tag -> as such:

<body>a quick test

<p>javascript</p>

<!--javascript-->
<p><script>
document.write("hello world")
</script></p>

<p>php</p>

<!--php-->
<?php
Echo "hello world";
?>

</body>

</html>
Vicky
A: 

First of all, before saving any file related to PHP, You have to clear see in which format it is going to Save. Save the file in .php extension, for example : filename.php then execute it at WAMP server. You will find HELLO World.

Rahul Patil